我尝试使用Percolatorby Elasticsearch,但我遇到了一个小问题。
假设我们的文档如下所示:
{
"doc": {
"full_name": "Pacman"
"company": "Arcade Game LTD",
"occupation": "hunter",
"tags": ["Computer Games"]
}
}
我们注册的查询是这样的:
{
"query": {
"bool": {
"must": [
{
"match_phrase":{
"occupation": "hunter"
}
},
{
"terms": {
"tags": [
"Computer Games",
"Electronic Sports"
],
"minimum_match": 1
}
}
]
}
}
}
我得到:
{
"took": 3,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"total": 0,
"matches": []
}
而且我不知道我做错了什么,因为如果我terms从注册查询中删除并匹配occupation它,它会按预期工作,我会得到一个匹配项。
有什么提示吗?
更新 1
好的,我认为@Slam 的解决方案是正确的方向,但我仍然有一些问题:
我更新了标签映射,现在看起来像这样:
"tags": {
"store": True,
"analyzer": "snowball",
"type": "string",
"index": "analyzed",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
要渗透的新文件:
{
"doc": {
"full_name": "Pacman"
"company": "Arcade Game LTD",
"occupation": "hunter",
"tags.raw": ["Computer Games"]
}
}
当我尝试将上面的文档与 匹配时tags.raw,仍然找不到匹配项。我分析了字段tags.raw,但看起来它仍然会创建令牌computer,games并且running.