0

This is similar to the question posed here.

I have a query that works:

match (n:Campus {name:'Georgia Southern University'}) return n;

1 row 38 ms

However, I'm building a search feature where I'd like to be able to have a user type "georgia" and return a list of nodes from the Campus label index whose name is like "Georgia".

This query does not work in neo4j-community-2.0.0 (although it did in -M05):

match (n:Campus) where n.`name` =~ '(?i).*Georgia.*' return n;

0 row 29 ms

  1. Is my expression incorrect? Quite possible, knowing my handicap with regexes.
  2. Otherwise, is it possible to do a regular expression search on a label index?

Thanks!

Edit: More info, output from the neo4j-shell:

neo4j-sh (?)$ match (n:Campus {name:'Georgia Southern University'}) return n.name;
+-------------------------------+
| n.name                        |
+-------------------------------+
| "Georgia Southern University" |
| "Georgia Southern University" |
+-------------------------------+
2 rows
45 ms
neo4j-sh (?)$ match (n:Campus) where n.`name` =~ '(?i).*Georgia.*' return n;
+---+
| n |
+---+
+---+
0 row
10 ms
Community
  • 1
  • 1
BZMac
  • 11
  • 3
  • You might also check out the RC1 release blog post with a note on a manual upgrade procedure: http://blog.neo4j.org/2013/11/neo4j-200-rc1-final-preparations.html – Michael Hunger Dec 16 '13 at 01:18

2 Answers2

2

Tried your query in 2.0.0-RC1 and it works fine:

CREATE (n:Campus {name:'Georgia Southern University'}) RETURN n
CREATE (n:Campus {name:'lil georgia'}) RETURN n
CREATE (n:Campus {name:'CAP GEORGIA CAP'}) RETURN n
CREATE (n:Campus {name:'East Georgia Tech'}) RETURN n


MATCH (n:Campus) 
    WHERE n.`name` =~ '(?i).*georgia.*'
    RETURN n    

...

Returned 4 rows in 156 ms
cod3monk3y
  • 9,508
  • 6
  • 39
  • 54
  • Thanks for the info, @cod3monk3y; I'm using the released "stable" version from 12/11/2013. Maybe something wrong with my index? Is there a way to check the indexes? Would my first query have worked if the index was messed up? – BZMac Dec 13 '13 at 15:11
  • I see your new output. How strange! What platform are you on? Could you create a new database and run the 5 statements I listed above to see if they work in a fresh environment? – cod3monk3y Dec 13 '13 at 15:38
  • I'm on Ubuntu 13.04. I am trying the Debian package install now. Having trouble getting it to recognize the limits.conf setting. I'll try your statements to see what's up. Seeing your code above makes me realize I'm just using labels to search, and the index should just make the search faster. Right? – BZMac Dec 13 '13 at 16:20
  • Yours worked! It must be my database...I uncommented the "allow_store_upgrade=true" in "neo4j.properties" but it's still not working. Thanks for your help! – BZMac Dec 13 '13 at 16:33
1

Solved, thanks to @cod3monk3y. I was upgrading my database from the neo4j-community-2.0.0-M05 version to the new stable version. The clean database test above led me to believe it was my database. Apparently the upgrade process during startup failed in terms of labels.

If I use the "rm -l" command to remove a label, then use "set" to set the same label again, the search works.

neo4j-sh (0)$  match (n:Campus {name: 'Boise State University'}) return id(n), n.name;
+----------------------------------+
| id(n) | n.name                   |
+----------------------------------+
| 2772  | "Boise State University" |
+----------------------------------+
1 row
77 ms
neo4j-sh (0)$ match (n:Campus) where n.`name` =~ '(?i).*Boise.*' return n;
+---+
| n |
+---+
+---+
0 row
215 ms
neo4j-sh (0)$ cd 2772
neo4j-sh (Boise State University,2772)$ ls
:Campus (plus a lot of other properties)
neo4j-sh (Boise State University,2772)$ rm -l Campus
neo4j-sh (Boise State University,2772)$ set -l Campus
neo4j-sh (Boise State University,2772)$ match (n:Campus) where n.`name` =~ '(?i).*Boise.*' return n.`name`;
+--------------------------+
| n.`name`                 |
+--------------------------+
| "Boise State University" |
+--------------------------+
1 row
72 ms

I used the code below previously to set labels up in the first place (the _handle property is one I set to group nodes before labels came about):

match n where n._handle='Campus' set n:Campus return Id(n), n.name, labels(n) order by Id(n);

I'll just modify it to remove the old labels, then re-set them.

BZMac
  • 11
  • 3
  • Glad to have helped. I'm pretty new to Neo4j so I haven't been through an upgrade phase and can't comment on labeling/indexing performance or failure to upgrade properly. Good to see you found a fix that works for you. (p.s. an up-vote on my answer would be nice, though yours is clearly the right solution. thanks!) – cod3monk3y Dec 13 '13 at 20:54
  • I'd upvote you but I don't have a 15+ reputation yet. :) – BZMac Dec 16 '13 at 15:11