Create and Query Full-Text Index

Your next task is to create a full-text index using Cypher.

Create a full-text index

We’ll create a full-text index on our movie nodes on the plot property. This will allow us to search for specific phrases or words within our movie plots. Note we already have a posterEmbedding property on our Movie nodes that we can use for vector search. Having both a full-text and vector index on these properties will allow us to do hybrid search in the future.

cypher
CREATE FULLTEXT INDEX plotFulltext IF NOT EXISTS
FOR (m:Movie)
ON EACH [m.plot]

Show Indexes

cypher
SHOW FULLTEXT INDEXES

You should see a result similar to the following:

id

name

state

populationPercent

type

1

"plotFulltext"

"ONLINE"

100.0

"FULLTEXT"

Once the state is listed as "ONLINE", the index will be ready to query.

Querying the Index

You can use the db.index.fulltext.queryNodes procedure to query the full-text index.

cypher
CALL db.index.fulltext.queryNodes("plotFulltext", "1375 imperial china")
YIELD node, score
RETURN node.title, node.plot, score

The second argument to queryNodes ("1375 imperial china") is your search term. The result will be nodes that have plots containing or closing matching this phrase, along with their relevance scores. Change this query to search for different phrases and see what results come back. See how the results differ from those results returned from querying a vector index.

Continue

When you are ready, you can move on to the next task.

Summary

You learned how to create and query a full-text index in Neo4j.

Next, you will learn how to model unstructured data as a graph.