Neo4j Built-in Full Text Auto Node Index

When launching the built-in Neo4j in the configuration, the automatic node index is not set as the full text by default (this means that all Lucene requests are case sensitive). How to set up an automatic index for full-text search?

0
source share
1 answer

First you need to do this in the new database. An automatic index is created lazily, which means that it is not created until first access. You have before first access to complete this configuration. If you try to change a property after it is created, it will not work. So, the first step is to load the database with automatic indexing enabled (node ​​or relationships).

val db = new GraphDatabaseFactory().newEmbedddedDatabaseBuilder("path/to/db"). setConfig(GraphDatabaseSettings.node_keys_indexable, "label,username"). setConfig(GraphDatabaseSettings.node_auto_indexing, "true").newGraphDatabase() 

Now, before you do anything, you must set the configuration properties. You can find out about the possible properties and values here . For this we need only two lines.

 val autoIndex = db.index.forNodes("node_auto_index") db.index.setConfiguration(autoIndex, "type", "fulltext") 

And all this to him. Now you can create vertices and relationships, and an automatic index will be created and populated. You can use the following code to query using Lucene query .

 autoIndex.getAutoIndex.query("label:*caseinsensitive*") 
+3
source

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


All Articles