Sphinx多值属性过滤器 [英] Sphinx multi value attribute filter

查看:108
本文介绍了Sphinx多值属性过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,每个标签都有唯一的ID.不必将这些唯一的ID存储在表中.我可以用这种方式存储它们……

Yes, each tag has unique Id. It is not necessary that I have to store these unique id's in a table. I can store them in this way…

$tags = array("Music","Sports","Food","Books",………)

对我来说,数组是最好的方法,因为它很容易更改.此外,数组键本身将用作唯一的ID.

Array is the best way for me as it is easily alterable. Moreover the array keys itself will serve as the unique Id's.

但是我的情况更为紧急,所以让我详细说明一下情况.

But my situation is more critical, so let me elaborate the exact situation.

我只有一个表格,其中包含ID,标题,说明,标签等字段,等等.

I have a single table with fields like Id, Title, Description, Tags, etc. etc. etc.

Id  |    Title      |  Description                     |  Tags  
1   | Sport & Hygine| With sport & music good food is …| Sport, Food
2   | Rock Concert  | Great Rock Show at …             | Music, Dance

如果用户选择(过滤器)显示记录,则在标记"字段中具有音乐".尽管标题和描述在第二行中完全没有音乐"一词,但仍应优先考虑.还应注意,标题"和描述"是文本字段,狮身人面像应搜索为标题和描述"赋予适当权重和等级的常规方法.但是标签"字段不能作为文本索引进行搜索.标签字段需要过滤.

If a user selects (filter) to show records, that has Music in the Tags field. Although the Title and description does not have the word Music at all in the second row, but still it should get the first priority. Also it should be noted that Title and Description are text fields and Sphinx should search the normal way giving appropriate Weights and Ranks to Titles and Description. But Tags field cannot be searched as text indexing. Tags field needs to be filtered.

因此,在上面的示例中,如果选择了音乐",则仅应显示第2行,因为它是根据标记"进行过滤的,而第2行"的标记"字段中只有音乐".但是,描述"字段的行1"中也存在音乐",但此处应将其忽略.我希望我能够澄清这种情况.任何对此的帮助都将受到高度赞赏.

Therefore, in the above example, if Music is selected, then row 2 should only be displayed, because it is filtered based on Tags and Row 2 only has Music in the Tags field. But Music is also present in Row 1 in the Description field, but here it should be ignored. I hope I am able to clarify the situation. Any hep with this is highly appreciated.

推荐答案

唯一标识在所有文档中都必须是唯一的.这样,运动"在所有文档上都具有相同的ID,因此可以使用相同的ID进行搜索.因此,您搜索的是ID,而不是单词.

The unique-id needs to be unique across all documents. So that "Sports" would have the same ID on all documents, and therefore the same ID can be used for searching. So you search for the ID, not the word.

因此标签可用于影响排名,您可以将其放在字段中.但是还可以将标记ID存储在MVA中,因此可以用于setFilter.

So the tags can be used to influence ranking, you can put them in a Field. But ALSO store the tag-ids in a MVA, so can use for setFilter.

类似

音乐@tags音乐

应作为扩展查询.因为它在标签中需要音乐"一词.但第一个学期也将匹配所有领域并有助于排名.

should work as an extended query. BEcause it requires the word Music in Tags. But also the first term will match all feilds and help with ranking.

这篇关于Sphinx多值属性过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆