Question

I´m using:

  • neo4j 2.0.1
  • spring data neo4j 3.0.1.RELEASE

I have a Node Person with the property name and I would like to search with Lucene syntax on that property. I´m using the findByNameLike method in my repository and that works perfect for query like value* or *value or * etc.

But I need a query like that {A* TO D*}. I found a deprecated method findAllByQuery("name", query) and with that method I can achieve my needs.

  1. I was wondering what is the new method not deprecated that understand such query syntax.

  2. I also noticed that if I create node from cypher, the node are not available in my search. With SDN I think that the generated node will be automatically add also to the index, but I don´t know how to check that and what is the index name. I must generate the node from cypher to have some base data in all my system. Should I add some special property in my cypher query?

Was it helpful?

Solution

First of all, make sure you understand the differences between the legacy (deprecated) Lucene indexes and the newer Schema indexes.

I was wondering what is the new method not deprecated that understand such query syntax.

You'll have to use one of the methods of the SchemaIndexRepositry which is extended in the GraphRepository interface for convenience. Bear in mind that e.g. wildcard searches are not yet implemented on schema indexes. If you want to use wildcard searches, you'll have 2 options. Continue to use the Lucene indexes (your best option for now), or use a regex query in a custom repository method. E.g.

MATCH (p:Person) WHERE p.name =~ ".*test.*" RETURN p

I also noticed that if I create node from cypher, the node are not available in my search. With SDN I think that the generated node will be automatically add also to the index, but I don´t know how to check that and what is the index name. I must generate the node from cypher to have some base data in all my system. Should I add some special property in my cypher query?

If you're using Lucene indexes, new entries will not be added to the index. AFAIK, you can only to that programatically. Schema indexes can be created as follows:

CREATE INDEX ON :Person(name)

New entries with the name property will be automatically added to the index. Again, wildcard searches will not yet use these indexes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top