Search boosting

Enonic version: 6.4.2
OS: Mac and Linux

Does search in Enonic support boosting? I know Elasticsearch does…

Although I’m a bit unsure about what you’re asking, it looks like search ordering is based on a _score value. The docs looks quite meaty on this subject (search in general), so perhaps your answer lies there?

1 Like

If you mean you want, for instances, hits in title to weigh more than hits in the body text then yes we do =)

Just use the query function from lib-content and something like this:

query: "fulltext('displayName^5, _alltext', '" + searchText + "~2', 'OR') ", sort: "_score DESC"

This searches for searchText in the entire index, with ~2 to allow for some minor spelling mistakes. But, with ^5 we make sure that any hit in displayName will have five times the weight of hits in anything else.

_allText is a small little gem (undocumented?) that contains all the indexed data for the domain you search in.

sort: "_score DESC" is the last piece of the puzzle, it does what you would think it does =)


dope @bwe! Love that!

1 Like

Correct Bobby. The _allText-fields are documented here:

The query-functions are documented here:

We are planning to make indexing more powerful by adding user configuration on how stuff should be indexed, e.g user-defined virtual fields ( e.g map all product.* fields of type text into a collection called products.allTextFields ), but thats for the future.

1 Like