graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Add ability to specify minimum score for fulltext index search

Open darrellwarde opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Full-text searches can return a lot of results, and filtering on the search score can help minimise the results.

Describe the solution you'd like

It should be possible to set a default value for this, and also override it per query.

For instance, this could be applied to a type like so:

type Movie @fulltext(name: "MovieTitle", fields: ["title"], defaultMinimumScore: 1) {
  title: String!
}

And also when querying like so:

query {
  movies(fulltext: { MovieTitle: { phrase: "Forrest", minimumScore: 2 } }) {
    title
  }
}

EDIT: another option is allowing minimum and maximum:

query {
  movies(fulltext: { MovieTitle: { phrase: "Forrest", score: { min: 2, max: 50 } } }) {
    title
  }
}

Additional context

An attempt at this functionality was removed in #1196, because the implementation was flawed in that it checked for an exact score match rather than a minimum.

darrellwarde avatar Mar 29 '22 16:03 darrellwarde

What about just adding the score returned from db.index.fulltext to the returned node in some way? Access to the score value would enable any user defined logic to be implemented.

trondaal avatar May 08 '22 09:05 trondaal

What about just adding the score returned from db.index.fulltext to the returned node in some way? Access to the score value would enable any user defined logic to be implemented.

I think that's a good idea in principle, but I think it will be a very messy addition to just add it into the returned node. I've raised an issue #1373 to capture how we might do this in future.

darrellwarde avatar May 09 '22 11:05 darrellwarde

This feature is now supported if you use the root-level queries generated for full-text indexes.

darrellwarde avatar Feb 21 '24 11:02 darrellwarde