How lucen works with Neo4j

I am new to Neo4j and Solr / Lucene . I read that we can use the lucene request in Neo4j, how does it work? What is the use of lucene query in Neo4j.?

And also I need a suggestion. I need to write an application for searching and analyzing data. which might help me Neo4j Or Solr?

+5
source share
1 answer

Neo4J uses lucene as part of obsolete indexing . Now Neo4J supports several types of indexes, for example, creating shortcuts on nodes and indexes in node properties.

But before neo4j supported these new features, it primarily (and still) used Lucene for indexing. Most developers created lucene indexes for specific node properties to allow them to use lucene query syntax to search for nodes in a cypher request.

For example, if you created the index according to the documentation , you can search for the index for specific values โ€‹โ€‹as follows:

 IndexHits<Node> hits = actors.get( "name", "Keanu Reeves" ); Node reeves = hits.getSingle(); 

It is lucene backstage that actually do it.

In cypher, it might look like this:

 start n=node:node_auto_index('name:M* OR name:N*') return n; 

In this case, you are looking for a specific index for all nodes that have a name property that starts with either "M" or "N". That inside this single quote expression is just a query according to the lucene query syntax .

OK, since Neo4J uses lucene. In recent versions, I use only these "obsolete indexes" for full-text indexing, where the strength is lucene. If I just need quick equality checks (where name = "Neo"), I use regular neo4j schema indices .

As for Solr, I have not seen it used in conjunction with neo4j - maybe someone will jump and present a counter example, but usually I think of Solr as launching over the large lucene index, and in the case of neo4j, it seems to be in the middle and I'm not sure Solr will be a good fit.

As you need to write an application for searching and analyzing data, I canโ€™t give you recommendations - either Neo4J or Solr can help depending on your application and what you want to do. In general, use neo4j when you need to express and search for graphs. Use Solr more when you need to organize and search for large volumes of text documents.

+11
source

Source: https://habr.com/ru/post/1204251/


All Articles