我有以下查询
{
"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
为什么不返回任何内容?因为我只希望结果与“peth goh”匹配。
最佳答案
由于尚未添加任何样本数据和索引映射,(考虑到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"
}
}
]
关于elasticsearch - OrchardCore match_phrase不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63521507/