Searching a particular index using Sphinx, from multiple indexes, through PHP script

独自空忆成欢 提交于 2019-12-10 11:26:47

问题


I have multiple sources, like this (say)

source src1{
...
}
source src2{
...
}

AND index src1{ ... } index src2{ ... }

src1 has sql query from one individual table and src2 has sql query based on another individual table.

Now, in the PHP script, how do I specify, which indexer to use? Normally, in the PHP script, we write it this way

$ss = new SphinxClient;
$ss->setServer("localhost", 9312);
$ss->setMatchMode(SPH_MATCH_ANY);

Since, there is no mention about the indexer being used. It's useless to search both indexes (i.e., both tables). I want to search the index src2(say) i.e., data from the second table. So, how do I specify this in my php script, that sphinx should search only that particular indexer.


回答1:


The Query call includes the index(s) to search

$res = $cl->Query($query,"src1");



回答2:


For one index (per Barry Hunter)

$res = $cl->Query($query,"src1"); 

or

For multiple indexes for one query.

$res = $cl->Query($query,"src1 src2 src3 src4");


来源:https://stackoverflow.com/questions/17494784/searching-a-particular-index-using-sphinx-from-multiple-indexes-through-php-sc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!