当前弹性映射:
"properties": {
"content": {
"type": "text",
"term_vector":"with_positions_offsets",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "russian"
}
}
字段" content“包含站点抓取的结果,准确地说是从标签中剥离出来的页面"body”标签内容。任务是实现对该字段的三种类型的搜索。1.所有指定的单词2.任何指定的单词3.准确地在文本中
对于1个案例-2个案例的match_phrase -3个案例的匹配-必须有match_phrase而不进行分析,因为它使用“俄语”分析器找到这个具有不同结尾和解密的phraze
尝试了此查询,但没有成功:
"query": {
"bool": {
"must": [
{
"match_phrase": {
"content": {
"query": "some search phraze",
"analyzer": "keyword"
}
}
}
]
}
发布于 2017-05-03 19:45:16
对于exact
匹配查询,请使用Term Query
。因此您的查询应该如下所示:
GET _search
{
"query": {
"term" : { "content.keyword" : "some search phraze" }
}
}
发布于 2017-05-04 02:56:15
自助回答
This answer对我帮助很大
将额外的字段"raw“添加到属性已解决的问题。
"properties": {
"content": {
"type": "text",
"term_vector":"with_positions_offsets",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"raw": {
"type": "text",
"index": "analyzed"
}
},
"analyzer": "russian"
}
}
搜索查询如下所示:
"query": {
"bool": {
"must": [
{
"match_phrase": {
"content.raw": {
"query": "some search phraze",
}
}
}
]
}
https://stackoverflow.com/questions/43758858
复制相似问题