V
V
Valery2013-10-15 10:04:02
Sphinx
Valery, 2013-10-15 10:04:02

Bring exact matches in Sphiinx search to first place?

Good afternoon,

let's say we are looking for the phrase "history of the city."

There is a section of the site, which is called "History of the city", i.e. full match to the field value.
And there is a section of the site that has a lot of words “history” and “city” in its content in various variations.

Sphinx ranks this second section higher than the first. In principle, I understand it - there are a lot of matches, but I need sections with a 100% match of the field with the request to be displayed from the very beginning.

How can this be implemented?

Solution:
use this ranking option:

$sphinxSearch->setRankingMode(SPH_RANK_EXPR, 'sum((4*lcs+2*(min_hit_pos==1)+exact_hit*100)*user_weight)*1000+bm25');

Exact_hit *100 is responsible for raising exact matches up

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kenny_opennix, 2013-10-15
@Akuma

I think sphinxsearch.com/docs/2.1.2/weighting.html will help
you
In particular SPH_RANK_EXPR

R
rakeev, 2013-10-15
@rakeev

sphinxsearch.com/docs/current.html#conf-index-exact-words
sphinxsearch.com/docs/current.html#conf-expand-keywords

D
dmrt, 2013-11-12
@dmrt

How can I make sure that only exact matches are displayed? No sign more, no sign less?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question