I'm trying to use the Neo4j 2.1.5 regex matching in Cypher and running into problems.
I need to implement a full text search on specific fields that a user has access to. The access requirement is key and is what prevents me from just dumping everything into a Lucene instance and querying that way. The access system is dynamic and so I need to query for the set of nodes that a particular user has access to and then within those nodes perform the search. I would really like to match the set of nodes against a Lucene query, but I can't figure out how to do that so I'm just using basic regex matching for now. My problem is that Neo4j doesn't always return the expected results. For example, I have about 200 nodes with one of them being the following: ( i:node {name: "Linear Glass Mosaic Tiles", description: "Introducing our new Rip Curl linear glass mosaic tiles. This Caribbean color combination of greens and blues brings a warm inviting feeling to a kitchen backsplash or bathroom. The colors work very well with white cabinetry or larger tiles. We also carry this product in a small subway mosaic to give you some options! SOLD OUT: Back in stock end of August. Call us to pre-order and save 10%!"}) This query produces one result: MATCH (p)-->(:group)-->(i:node) WHERE (i.name =~ "(?i).*mosaic.*") RETURN i > Returned 1 row in 569 ms But this query produces zero results even though the description property matches the expression: MATCH (p)-->(:group)-->(i:node) WHERE (i.description=~ "(?i).*mosaic.*") RETURN i > Returned 0 rows in 601 ms And this query also produces zero results even though it includes the name property which returned results previously: MATCH (p)-->(:group)-->(i:node) WITH i, (p.name + i.name + COALESCE(i.description, "")) AS searchText WHERE (searchText =~ "(?i).*mosaic.*") RETURN i > Returned 0 rows in 487 ms MATCH (p)-->(:group)-->(i:node) WITH i, (p.name + i.name + COALESCE(i.description, "")) AS searchText RETURN searchText > ... SotoLinear Glass Mosaic Tiles Introducing our new Rip Curl linear glass mosaic tiles. This Caribbean color combination of greens and blues brings a warm inviting feeling to a kitchen backsplash or bathroom. The colors work very well with white cabinetry or larger tiles. We also carry this product in a small subway mosaic to give you some options! SOLD OUT: Back in stock end of August. Call us to pre-order and save 10%! ... I then tried to cache the search text on the nodes and I added an index to see if that would change anything, but it still didn't produce any results. CREATE INDEX ON :material(searchText) MATCH (p)-->(:group)-->(i:node) WHERE (i.searchText =~ "(?i).*mosaic.*") RETURN i > Returned 0 rows in 3182 ms I then tried to simplify the data to reproduce the problem, but in this simple case it works as expected: MERGE (i:node {name: "Linear Glass Mosaic Tiles", description: "Introducing our new Rip Curl linear glass mosaic tiles. This Caribbean color combination of greens and blues brings a warm inviting feeling to a kitchen backsplash or bathroom. The colors work very well with white cabinetry or larger tiles. We also carry this product in a small subway mosaic to give you some options! SOLD OUT: Back in stock end of August. Call us to pre-order and save 10%!"}) WITH i, ( i.name + " " + COALESCE(i.description, "") ) AS searchText WHERE searchText =~ "(?i).*mosaic.*" RETURN i > Returned 1 rows in 630 ms What am I missing? I tried using the CYPHER 2.1.EXPERIMENTAL tag as well but that didn't change any of the results. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.