postgres sphinx 搜索顺序
postgres sphinx search order
我安装了带有 Sphinx 的 postgres,当我 运行 查询时,我希望首先选择最相关的记录。换句话说,我首先想要以下查询:
query="word1 & word2 & word3"
然后,如果没有选择,
query="word1 | word2 | word3"
如何根据需要配置 sphinx? Sphinx 配置是默认的
嗯https://github.com/andy128k/pg-sphinx说
sphinx_select(
/*index*/ varchar,
/*query*/ varchar,
/*condition*/ varchar,
/*order*/ varchar,
/*offset*/ int,
/*limit*/ int,
/*options*/ varchar)
从 http://sphinxsearch.com/docs/current.html#sphinxql-select 开始,您需要一个 OPTIONS 子句来更改排名(ranker
选项)
http://sphinxsearch.com/docs/current.html#weighting
所以会尝试
sphinx_select(...., "word1 | word2 | word3", ..., "ranker=wordcount")
(已编辑以显示查询,需要 OR 查询才能正常工作!请参阅上面的评论)
(wordcount ranker,非常基础,但应该做你想要的确切标准)
但可以玩自定义表达式,不是很好,但可以帮助您入门...
sphinx_select(...., "ranker=expr('sum(word_count+hit_count+lccs+exact_order)+bm25')")
更详细...http://sphinxsearch.com/blog/2010/08/17/how-sphinx-relevance-ranking-works/
我安装了带有 Sphinx 的 postgres,当我 运行 查询时,我希望首先选择最相关的记录。换句话说,我首先想要以下查询:
query="word1 & word2 & word3"
然后,如果没有选择,
query="word1 | word2 | word3"
如何根据需要配置 sphinx? Sphinx 配置是默认的
嗯https://github.com/andy128k/pg-sphinx说
sphinx_select(
/*index*/ varchar,
/*query*/ varchar,
/*condition*/ varchar,
/*order*/ varchar,
/*offset*/ int,
/*limit*/ int,
/*options*/ varchar)
从 http://sphinxsearch.com/docs/current.html#sphinxql-select 开始,您需要一个 OPTIONS 子句来更改排名(ranker
选项)
http://sphinxsearch.com/docs/current.html#weighting
所以会尝试
sphinx_select(...., "word1 | word2 | word3", ..., "ranker=wordcount")
(已编辑以显示查询,需要 OR 查询才能正常工作!请参阅上面的评论)
(wordcount ranker,非常基础,但应该做你想要的确切标准)
但可以玩自定义表达式,不是很好,但可以帮助您入门...
sphinx_select(...., "ranker=expr('sum(word_count+hit_count+lccs+exact_order)+bm25')")
更详细...http://sphinxsearch.com/blog/2010/08/17/how-sphinx-relevance-ranking-works/