Recipe: Full-Text Search

BM25-scored full-text search over node properties.

Create a full-text index#

db.mutate("CREATE FULLTEXT INDEX person_search FOR (n:Person) ON (n.name)")
const results = db.query("CALL db.index.fulltext.queryNodes('person_search', 'Alice')")
for (const row of results.rows) {
  console.log(row.get('name'), row.get('score'))
}

Search with a variable query#

const results = db.query(
  "CALL db.index.fulltext.queryNodes('person_search', $query)",
  { query: userSearchTerm }
)

Multi-property index#

db.mutate("CREATE FULLTEXT INDEX doc_search FOR (n:Document) ON (n.title, n.body)")

List existing indexes#

const indexes = db.query("CALL db.fulltextIndexes")

See Also#

  • Vector Search — semantic (embedding-based) search alongside full-text
  • Trusted RAG — confidence-filtered retrieval combining full-text and graph
  • Indexes — index creation and management
Try it
Open ↗
Loading engine…