【发布时间】:2016-01-13 21:14:52
【问题描述】:
示例数据:
PUT /test/test/1
{
"text1":"cats meow",
"text2":"12345",
"text3":"toy"
}
PUT /test/test/2
{
"text1":"dog bark",
"text2":"98765",
"text3":"toy"
}
还有一个示例查询:
GET /test/test/_search
{
"size": 25,
"query": {
"multi_match" : {
"fields" : [
"text1",
"text2",
"text3"
],
"query" : "meow cats toy",
"type" : "cross_fields"
}
}
}
返回 cat 先命中,然后是 dog,这就是我想要的。
但是当您查询cat toy 时,猫和狗的相关性得分相同。我希望能够考虑该单词的前缀(可能还有该字段中的其他几个单词),然后运行cross_fields。
所以如果我搜索:
GET /test/test/_search
{
"size": 25,
"query": {
"multi_match" : {
"fields" : [
"text1",
"text2",
"text3"
],
"query" : "cat toy",
"type" : "phrase_prefix"
}
}
}
或
GET /test/test/_search
{
"size": 25,
"query": {
"multi_match" : {
"fields" : [
"text1",
"text2",
"text3"
],
"query" : "meow cats",
"type" : "phrase_prefix"
}
}
}
我应该得到 cat/ID 1,但我没有。
我发现使用cross_fields 可以实现多词短语,而不是多不完整短语。而phrase_prefix 实现了不完整的词组,而不是多个不完整的词组...
筛选documentation 确实无助于我发现如何将这两者结合起来。
【问题讨论】:
标签: elasticsearch