Home > Back-end >  Extracting bucket name from CNAME record using Neo4j
Extracting bucket name from CNAME record using Neo4j

Time:08-22

The CNAME data is stored in node B.type. the value is s3.us-east-2.amazonaws.com/test.my-domain.com/index.html. What should be the best way to extract the bucket name here(test.my-domain.com) using cypher query in the WHERE statement? I tried using substring but could not eliminate index.html.

CodePudding user response:

You can use split function and pick the element at index 1:

MATCH (b:B)
WITH b, split(b.type, '/')[1] AS bucketName 
WHERE bucketName = your_condition
RETURN b

Here, we are using WITH clause to store bucket name in a new variable, so that we can easily use it in WHERE clause without recalculating it.

  • Related