我有两个独立的实体,项目和用户,彼此之间没有关系。
由于复杂的连接等,我选择使用xmlpipe2数据源而不是mysql。
我希望用户能够同时搜索用户和项目。
我的Project xml源码:
<sphinx:document id="1">
<title>Project 1</title>
<details>some details bob</details>
</sphinx:document>
<sphinx:document id="2">
<title>Project 2</title>
<details>some more details bob</details>
</sphinx:document>
...etc...
我的用户xml源:
<sphinx:document id="1">
<name>Bob Smith</name>
<age>16</age>
</sphinx:document>
<sphinx:document id="2">
<name>Dorathy Melton</name>
<age>22</age>
</sphinx:document>
...etc...
我有两个单独的项目和用户索引
现在在我的PHP代码中,如何同时搜索两个索引,比如
$s = new SphinxClient();
$res = $s->Query('bob', "projects users");
我希望来自项目和用户的一些匹配,但是它只搜索一个索引,因为两个索引的ID都相同。
我的备份解决方案,听起来不正确1.尝试将两组数据连接在一起并具有1个索引2.我运行两个单独的查询
$res = $s->Query('bob', "projects");
$res = $s->Query('bob', "users");
您可以抵消您的ID,因此他们不会在一个索引中的项目中使用<sphinx:document id="200002">
,而在用户中使用<sphinx:document id="300002">
。即只需为索引中的所有ID添加固定偏移量。