cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Select nodes based on a keyword/phrase using Full-text search index not working

Hi,

My DB has around 2 million nodes(10 different types of nodes) and 3 million relationships in total.

Problem:
I want to run a query on the DB and select a set of nodes (similar type) based on the presence of a keyword(or phrase) in one of their fields called 'Description'.
'Description' field is plaintext (around 10 lines of text).

So, I tried to make a Full-text search index on this field using the following command.

CREATE FULLTEXT INDEX Descriptions FOR (n:Nodename) ON EACH [n.Description]

This command completes after 1 second without any errors, and I can see the newly created index in the list of indexes.
But when I try to run my query, nothing returns. I guess there is something wrong with the index because I believe index creating should take some time in a massive DB like mine.

I used the following command to search and return the nodes:

CALL db.index.fulltext.queryNodes("Descriptions", "Keyword or Phrase") YIELD node, score
RETURN node.Description, score

Any idea about this problem?
Or any other solution for a fuzzy text search on a field based on a keyword/phrase?

Thanks.

10 REPLIES 10

Hello @mehdi.kh2012 and welcome to the Neo4j community

Can you try this query? I used a regex.

CALL db.index.fulltext.queryNodes("Descriptions", "(?i)*(keyword)|(phrase)*") YIELD node, score
RETURN node.description, score

Regards,
Cobra

Hi @Cobra, Thanks for your response.
Your command didn't retrieve anything either. I believe there is something wrong with the creation of the index. As I mentioned in my question, my index creation command completes after only 1 second. It seems to me that it is a bug. Index creation should take some time in a massive DB with millions of nodes.

Execute this query please:

SHOW FULLTEXT INDEXES

It looks like the property you want to index is on nodes with label "CVE". Maybe try this version of index creation:

CREATE FULLTEXT INDEX Descriptions FOR (n:CVE) ON EACH [n.Description]

The index is created so, can you add the PROFILE front of the query to check if the query uses the index?

Can you eloborate please?

Execute this query in Neo4j browser:

PROFILE CALL db.index.fulltext.queryNodes("Descriptions", "(?i)*(keyword)|(phrase)*") YIELD node, score
RETURN node.description, score

I am sure that I have hundreds of matches in my DB.