【发布时间】:2019-01-28 11:20:06
【问题描述】:
我需要获取Description 字段包含子字符串28/859 的文档。这是我的查询:
{
"explain": true,
"query": {
"bool":{
"filter":{
"bool":{"should":[{"query_string":{"default_field":"Description","query":"28//859",
"analyzer": "keyword"}}]}},
"must_not":{"exists":{"field":"ParentId"}}}
}
}
我得到的文件是:
-
28/859在Description字段中(没关系) - 但我也会在
Description字段中获得带有28的文档(我不需要它)
我怎样才能只获取带有子字符串28/859 的文档?
更新:解释示例:
{
"_shard": "[tech_places][4]",
"_node": "u7QI_gjjRXy4-xdqnK2KMw",
"_index": "tech_places",
"_type": "entity",
"_id": "8403",
"_score": 0.0,
"_source": {
"Id": 8403,
"Name": "RETE-43424",
"Description": "SRF-10kv №28 VISO",
"ParentId": null,
"OrganizationId": 12,
"OrganizationPath": "12_27",
"LocationId": 27,
"Classification": "",
"Type": "A",
"Status": 0,
"MaintenanceObjectId": null,
"TreePath": "8403"
},
"_explanation": {
"value": 0.0,
"description": "sum of:",
"details": [
{
"value": 0.0,
"description": "match on required clause, product of:",
"details": [
{
"value": 0.0,
"description": "# clause",
"details": []
},
{
"value": 0.0,
"description": "sum of:",
"details": [
{
"value": 0.0,
"description": "weight(Description:28 in 35112) [], result of:",
"details": [
{
"value": 0.0,
"description": "score(doc=35112,freq=1.0), with freq of:",
"details": [
{
"value": 1.0,
"description": "termFreq=1.0",
"details": []
}
]
}
]
}
]
}
]
}
]
}
},
【问题讨论】:
-
您能否在查询中添加 explain:true 并显示输出?
-
@Mysterion,我已经更新了我的问题。
标签: elasticsearch