摘录搜索词

时间:2014-10-20 10:22:36

标签: full-text-search sphinx

我正在使用Sphinx索引和搜索我的网站。

在搜索某个单词时,是否有办法返回摘录(搜索过的单词及其周围的几个单词)。

现在我正在使用这个包scalia

 $results = SphinxSearch::search($search, $index_type);

 // I Set match, sort and ranking mode
 $results
    ->setMatchMode($search_mode)
    ->setSortMode($sort_mode, $sort_column)
    ->setRankingMode(\Sphinx\SphinxClient::SPH_RANK_SPH04);
  //set field weights
  $results->setFieldWeights(array('title'  => 10,'content'=> 5));

  //and get results
  $results = $results->limit(300, 0, 1000, 100000)->query();

有没有办法管理Sphinx返回找到搜索关键字的文本摘录?

1 个答案:

答案 0 :(得分:0)

您需要SphinxAPI中的BuildExcerpts功能 http://sphinxsearch.com/docs/current.html#api-func-buildexcerpts

唉,扩展,似乎没有暴露功能,所以必须修改扩展,或者只是绕过它。