Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Support full text search #266

Closed
johnymontana opened this issue Jun 19, 2019 · 1 comment · Fixed by #543
Closed

Support full text search #266

johnymontana opened this issue Jun 19, 2019 · 1 comment · Fixed by #543

Comments

@johnymontana
Copy link
Contributor

Neo4j supports full text search through the use of procedures. For example:

to create a fulltext index:

CALL db.index.fulltext.createNodeIndex("businessNameIndex", ["Business"],["name", "description"])

this creates a full text index named businessNameIndex and adds the name and description properties on the Business node label to the index.

We can then search the index, for example:

CALL db.index.fulltext.queryNodes("businessNameIndex", "pizza~")

would search the index using the search string pizza and the ~ indicates a fuzzy text search, so slight misspellings will match.

Directives

We could use schema directives to indicate which full text indexes exist, or more usefully, which should be created. Something like:

type Movie {
  movieId: ID!
  title: String @neo4j_search(name: "movieIndex")
  description: String @neo4j_search(name: "movieIndex")
  year: Int

}

Filter

The schema augmentation process could pick up the @neo4j_search directives and add a field to the generated _MovieFilter type for the movieIndex. Then a query using this index would look something like this:

query {
  Movie(filter: {movieIndex: "matrix"}) {
    title
  }
}

which would then translate into something like:

CALL db.index.fulltext.queryNodes("movieIndex", "matrix")
YIELD node
RETURN node {.title} AS movie

this might be a bit tricky to support for nested filters, so perhaps a better route would be to expose the index as an argument on the Query fields.

See this blog post, this knowledge base article, and the docs for other examples of using full text search with Neo4j.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant