开发者

Prioritize fields which start with search term using Sphinx (Thinking Sphinx) - or another full-text search engine

I'm using sphinx and thinking sphinx to search a customer database. The customer metadata (emails, tels etc) are spread across multiple tables and sphinx indexes all notes on customers etc etc. The problem I'm having is that I want text fields which START with the search term to be displayed first in searches. i.e. a search for "hods" should return开发者_如何学JAVA results in the order:

  • Hods
  • The Hods
  • Hodson
  • Methods

which means should prioritize (roughly in this order):

  • Start of phrase
  • Complete words
  • Start of words

i've tried to achieve this with a composite search term (e.g. "^hods | hods | hods* | *hods").

Somthing like this can ensure I finds all the appropriate results - but doesn't seem to affect how they are ranked!! I can't find anything useful in the documentation either!!

Any ideas? Is this possible with Sphinx? Any other search solutions where this is possible?


Sphinx 1.10 introduces new ranking mode: SPH_RANK_SPH04.

You can set ranking mode with thinking-sphinx although it is not documented on its home page. I can't recall right now how I did it exactly, but it was very similar to setting other search params.


I've never used ThinkingSphinx, but I boost query terms all of the time in Lucene/Solr. There should be a similar mechanism in most searching tools.


(e.g. "^hods | hods | hods* | *hods")

this query does not prioritize results. the above query only decides what to fetch.

If you have to prioritize, you have to use ranking modes .. or sort modes probably.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜