LapinLove404
LapinLove404

Reputation: 1949

Thinking Sphinx : Relevance - infix vs. complete word

Using Thinking Sphinx in my rails app, I set it up to allow partial match with infix (for example, searching for "tray" would match "ashtray").

However, I'd like complete word match to have more weight (relevance) than infix match.

So, if my search for 'tray' returns these 3 results : "Silver Tray", "Ashtray" and "Some other tray" - I want the "Ashtray" to be the last result when sorting by relevance.

Is there a way to configure Sphinx to do that ?

Upvotes: 1

Views: 377

Answers (1)

srcspider
srcspider

Reputation: 11205

You need to define your own ranker. Here's how the default ones look like:

SPH_RANK_PROXIMITY_BM25 = sum(lcs*user_weight)*1000+bm25

SPH_RANK_BM25 = bm25

SPH_RANK_NONE = 1

SPH_RANK_WORDCOUNT = sum(hit_count*user_weight)

SPH_RANK_PROXIMITY = sum(lcs*user_weight)

SPH_RANK_MATCHANY = sum((word_count+(lcs-1)*max_lcs)*user_weight)

SPH_RANK_FIELDMASK = field_mask

SPH_RANK_SPH04 = sum((4*lcs+2*(min_hit_pos==1)+exact_hit)*user_weight)*1000+bm25

http://sphinxsearch.com/docs/2.0.6/weighting.html

Upvotes: 1

Related Questions