我有以下查询
{
"from": 0, "size": 10000,
"query": { "match_phrase": {"Practitioner.DoctorList": "peter goh"} },
}它不会返回任何结果。
但以下内容:
{
"from": 0, "size": 10000,
"query": { "match": {"Practitioner.DoctorList": "peter goh"} },
}返回包含"peter goh“、"peter”和"goh“的内容。
为什么match_phrase不返回任何东西?因为我只想让结果与"peter goh“匹配。
发布于 2020-08-21 22:07:12
因为您还没有添加任何示例数据和索引映射(考虑Practitioner是nested类型)
请参阅match_phrase查询,以获取详细信息
添加一个包含索引数据、映射和搜索查询的工作示例。
索引映射:
{
"mappings": {
"properties": {
"Practitioner": {
"type": "nested"
}
}
}
}索引数据:
{
"Practitioner": [
{
"DoctorList": "goh"
},
{
"DoctorList": "peter goh"
},
{
"DoctorList": "peter"
}
]
}搜索查询:
{
"query": {
"nested": {
"path": "Practitioner",
"query": {
"match_phrase": {
"Practitioner.DoctorList": "peter goh"
}
},
"inner_hits":{}
}
}
}搜索结果:
"hits": [
{
"_index": "fd_cb3",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "Practitioner",
"offset": 1
},
"_score": 0.78038335,
"_source": {
"DoctorList": "peter goh"
}
}
]https://stackoverflow.com/questions/63521507
复制相似问题