Per content-type weighting in Enhanced Search


Well-known member
I've been creating a new add-on which implements some advanced search functionality to bolt onto Enhanced Search. MySQL-based search is not supported, nor planned, and this add-on only works with Enhanced Search.

This add-on injects per-content type weighting for general searches with more than one content type. Then sorting by relevancy is enabled; the weighting is multiplied by the arbitrary score Elastic Search computes for each item.

The new per-content type weighting options are under 'Search Options'.

Please do not deploy this to a Live site, as it is still under development and I haven't tested it extensively!

We on AVForums want to use ES to weight the search results so that items in our products table are returned with the highest priority, then reviews, news and articles, then user reviews, then competitions, then threads.
I'm told this is not easy.
I have a alpha copy of my Search Improvements add-on with this functionality now here. I need to experiment with the exacts of how the weighting is applied as it really isn't easy to determine what is a sane value to weight each content-type.

I'ld love some feedback on this add-on so far. But please don't deploy it to your live site yet!

Basically you'd want to make a "_priority" type field and have products be 100, reviews 90, news and articles 80, etc (I'm leaving gaps to allow more content types to squeeze in later if you want). Then you would have to switch the scripting that XenForo uses. Currently it's something like:
I've implemented a query-time priority, but I'm not happy about the implementation due to the lack of flexibility with the XenForo Elastic Search API bits.