graphql
graphql copied to clipboard
Add ability to specify minimum score for fulltext index search
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.
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.
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.
This feature is now supported if you use the root-level queries generated for full-text indexes.