Lx2pwn
Lx2pwn

Reputation: 323

query with regex in neo4j doesn't return the correct result

I'm tring to execute this query without succes

MATCH (t:Tweet)
WHERE  
    t.full_text =~ '(?i).*sciacalli.*'  AND
    t.created_at>'2018/01/01' AND t.created_at<'2020/04/25'
RETURN t

The output shuld be this one

"full_text": "RT @catlatorre: Sciacalli.\n
                  Comunque vada sempre sciacalli 
                  siete #KobeBryant https://t.co/*********",
"created_at": "2020/01/26 22:49:51",

I don't understand way the regex not match

But if modify the query as follow

MATCH (t:Tweet)
WHERE  
    t.full_text CONTAINS 'sciacalli'  AND
    t.created_at>'2018/01/01' AND t.created_at<'2020/04/25'
RETURN t

I get the correct result. What's wrong ?

Upvotes: 0

Views: 43

Answers (1)

Brant Boehmann
Brant Boehmann

Reputation: 125

Your value contains line endings. Include the DOTALL option with ?s

MATCH (t:Tweet)
WHERE  
    t.full_text =~ '(?is).*sciacalli.*'  AND
    t.created_at>'2018/01/01' AND t.created_at<'2020/04/25'
RETURN t

Upvotes: 1

Related Questions