开发者

How do I set more specific rules for sphinx query?

I have a database with list of movies and tv series. The search I built uses Sphinx.

I use SPH_MATCH_ANY mode, because I want that if a person search for "x-men 2" he will also find entries about "x-men 1" and "x-men 3".

My problem is, it also searches for entries with "2", for example "Cars 2", or "Supernatural season 2".

I want to tell it not to search entries that have no 'x-men" in them. In MYSQL I would write it like this:

MATCH (mname) AGAINST ('x-men') AND mname like '%x-men%' 

or something like that.

In Sphinx I tried this:

$s->Query(x-men 2 "x-men",'test1');

But It still searched for 开发者_Python百科entries with the number "2" in them..

So how can I accomplish that?

Thank you.


Ok problem solved, a guy from Sphinx forum gave me this solution:

$s->setMatchMode(SPH_MATCH_EXTENDED2);
$s->Query("(x-men | 2) x-men",test1);
$s->setRankingMode(SPH_RANK_ANY);

=)


You need to think like a computer... for us is quite obvious that the word "x-men" is more relevant than "2", but for a computer they are both equal.

You could always tell sphinx to index "x-men 1","x-men 2" and "x-men 3" to the same index, using the wordforms

x-men 1 > xmen
x-men 2 > xmen
x-men 3 > xmen

so if someone searches for "x-men 2" he will see the results for the 3 movies. Or you could tell sphinx not to index single numbers, or set the min length for indexes.

But then the users might complain that they wanted ONLY to see the info of "x-men 2" and not the other movies.

In my opinion, when configuring a search engine you don't have to guess what the user wants as a result, because different users will expect different results, but you should always give him the tools to refine his search. For example, one person would expect that x-men 2 returns all x-men movies, another person would expect it to return info related only to x-men 2, and (why not?) someone will expect it to return all movies containing the words "x-men" and "2"... you can't make everybody happy =P

Good Luck

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜