Global search, orderby most matches?

Hi,

In a typical getContentByQuery or getContentByCategory, is it possible to order the result by most matching cases?

Enonic version: 4.7.11
OS: YourOS

Hi.

Do you mean by ordering by score? By default, results are ordered by score:

https://www.elastic.co/guide/en/elasticsearch/guide/master/scoring-theory.html

Meaning that e.g boolean expression queries should order the hit with the most matching clauses first etc.

Do you have an example of what you are trying to achieve?

1 Like

Thanks.
So if “orderby” remains emtpy. The order will be by ranking?
Is it possible to extract the score and expose it to the portlett?

Don’t really have an example, just curious how much customizing is possible for the search.
E.g if the word is contained in title, it should be x time relevant than if its used in a preface and y times in link texts.

Yes, we support boosting of fields:

http://xp.readthedocs.org/en/stable/developer/search/query-functions/fulltext.html

At the moment, the score is sadly not in the result, but the task to expose this and other meta-data from the search-phase is in the pipe :slight_smile:

is this also possible in 4.7?

Oh, didnt see the 4.7 tag there, sorry.

The search capability in 4.7 is somewhat limited compare to XP. There is no field boosting, but the default ordering should be score here also.

2 Likes

Hi, piping in with the same problem in XP 6.4.1. Sorry if I’m hijacking the topic.

I’m boosting the importance of a field, but the default ordering of a query result is modifiedTime DESC. This means that my boosting is having no actual effect on the result set.

Is it possible to order by search relevance score in 6.4.1?

That sir, seems like an awful error in the documentation. I did some testing now to be sure:

Created an input-type with a double value, and did a number of queries.

Here are the queries:

And the result:

Have you seen indications about this not working @Jonas, or is it just the horrible documentation-error?

The documentation tricked me!!! :rage:

Thanks for clearing this up for me :sweat_smile:

Still not in the result when querying? Would be great to get it to decide if hits are good enough and perhaps perform alternate way of fetching result.

This is implemented for the node-lib, but not for content-lib.

There are no meta-data for the content results now, which makes it a bit harder to add without running into backward compatibility-issues (adding it to the content fields is a bit dirty). Ill add a task for us to see what we can do.