Search results sorted by relevance

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x] Documentation issue or request

Current behavior

When we do a search on a query with GraphQL we get the data we want with order of appearance or we can order by item field.

Expected behavior

We want to know if the data could be ordered or ranked by the quality of the match. Example: if I search the word “Test” and it is found on two fields (imagine title and content) we want the result list to be order by the items that has the founded word on the title and then the ones on the content.

Minimal reproduction of the problem

No issue

Environment

App Name:

  • [x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: dev-7133

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Hi,

thanks for your feature request. Right now this has not been implemented yet and I am not sure if it is possible.

But I can have a look.

Sebastian

EDIT: I think it is not possible. The full text is an external system, so it works like in the following pseudo code snippet. Consider you want to get 20 items:

var @ids = SELECT TOP 2000 id from FullText WHERE Search('Test')

var @contents = SELECT TOP 20 * FROM Contents WHERE id IN @ids;

So the problem is that you get first 20 items from the Id List @ids but based on the sorting you specify in the second query. And “relevance” is nothing you have available here.

You can also not sort in on the server because you have restricted the result set. So the only option would be something like this:

var @ids = SELECT TOP 2000 id from FullText WHERE Search('Test')

var @contents = SELECT TOP 2000 * FROM Contents WHERE id IN @ids;

@contents = SORT @contents  BY @ids DESC;
@contents = TAKE 20 FROM @contents;
1 Like