1

I am using neo4j.rb as the ORM for a Rails app, talking to a simple neo4j schema. I have a bunch of Person nodes and each node has two fields name and bio.

My goal is to be able to (a) search for people using a fuzzy name search which is case insensitive; (b) be able to do a full text search of the bio.

I am very confused about how indexing/searching works in neo4j. Not sure I fully understand the difference between 'schema' and 'legacy' indexing, or how Lucene fits into all of this. Most importantly, I do not understand which features neo4j.rb actually supports.

Thanks in advance.

Jake
  • 15,007
  • 22
  • 70
  • 86

1 Answers1

2

I'm one of the maintainers of the Neo4jrb project. Indexing is pretty confusing for everyone but I can break it down pretty easily for you.

The gem doesn't deal with legacy indexing at all. The "legacy" designation suggests to us that it's not going to be around forever and that coupled with the fact that it's a bit clunky to use led us to decide not to implement it. Everything in the gem uses labels and property indexes, which are all Lucene exact indexes under the hood.

When it comes to search, if you want case insensitive and/or full-text search, you can do that in Cypher and the gem but it's going to work outside of indexes and it may be sluggish. It all depends on your data. This shows you how to do regex with Cypher. In the gem, you can do it like this:

User.where(name: /?ob/)
# or
User.as(:u).where("u.name =~ '?ob`")

My personal suggestion is to use the Searchkick gem to provide these features. It uses Elasticsearch, which uses Lucene, which is what Neo4j is using anyway, so you'll get more control and the same performance as you would with legacy indexing. The downside is you have one more moving part of your setup, but I think it's worth it.

Hope this clears it up. I'm going to add an area to the wiki about it since it's a pretty common question. Post here, open an issue on Github, or shoot me an email if you want to talk more about it.

EDIT: I added this to the documentation.

subvertallchris
  • 5,282
  • 2
  • 25
  • 43
  • Want to point out that I tried starting this with "Hey Jake" but StackOverflow thinks it's important that we all present ourselves as soulless robots so it edited my post. – subvertallchris Oct 24 '14 at 21:55
  • Hi, thanks for your detailed post! I ended up using searchkick, as you suggest, and it's working out nicely. Would be great to see this in the neo4j.rb wiki, and thanks for all your efforts with that gem. – Jake Oct 25 '14 at 22:48