Neo4j regex string matching not returning expected results

折月煮酒 提交于 2019-12-06 11:16:53

just a few notes:

  • probably replace create unique with merge (which works a bit differently)
  • for your fulltext search I would go with the lucene legacy index for performance, if your group restriction is not limiting enough to keep the response below a few ms

I just tried your exact json statement, and it works perfectly.

inserted with

curl -H accept:application/json -H content-type:application/json -d @insert.json \
     -XPOST http://localhost:7474/db/data/transaction/commit

json:

{"statements":[
    {
    "parameters":
        {
        "p01":"lsF30nP7TsyFh",
        "p02":
            {
            "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%!",
            "id":"lsF3BxzFdn0kj",
            "name":"Linear Glass Mosaic Tiles",
            "object":"material"
            }
        },
    "resultDataContents":["row"],
    "statement":
        "MERGE (p:project { id: { p01 } })
        WITH p

        CREATE UNIQUE (p)-[:MATERIAL]->(:materials:group {name: \"Materials\"})-[:MATERIAL]->(m:material  { p02 }) RETURN m"
    }
]}

queried:

MATCH (p)-->(:group)-->(i:material)
 WHERE (i.description=~ "(?i).*mosaic.*")
 RETURN i

returns:

name:   Linear Glass Mosaic Tiles
id: lsF3BxzFdn0kj
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%!
object: material

What you can try to check your data is to look at the json or csv dumps that the browser offers (little download icons on the result and table-result)

Or you use neo4j-shell with my shell-import-tools to actually output csv or graphml and check those files.

Or use a bit of java (or groovy) code to check your data.

There is also the consistency-checker that comes with the neo4j-enterprise download. Here is a blog post on how to run it.

java -cp 'lib/*:system/lib/*' org.neo4j.consistency.ConsistencyCheckTool /tmp/foo

I added a groovy test script here: https://gist.github.com/jexp/5a183c3501869ee63d30

One more idea: regexp flags

Sometimes there is a multiline thing going on, there are two more flags:

  • multiline (?m) which also matches across multiple lines and
  • dotall (?s) which allows the dot also to match special chars like newlines

So could you try (?ism).*mosaic.*

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!