【发布时间】:2015-09-02 14:30:29
【问题描述】:
我需要一种在“字符串”和“整数”类型的两个或多个字段上使用纯精确匹配来搜索文档的方法。
我想避免标准查询,因为我不关心得分或最佳匹配,如果两个字段都匹配,则只关心是/否结果。
我知道我可以使用过滤器来做到这一点,但我只得到了使用 JSON 格式的示例查询。我想在 C# 环境中进行这样的搜索。
这是我的映射:
{
"reviewer-test-index": {
"aliases": {},
"mappings": {
"historyRecord": {
"properties": {
"groupName": {
"type": "string"
},
"groupNo": {
"type": "integer"
},
"instrType": {
"type": "integer"
},
"instrumentAddress": {
"type": "string"
},
"insturmentName": {
"type": "string"
},
"macAddr": {
"type": "string"
},
"uhhVersion": {
"type": "string"
}
}
},
"settings": {
"index": {
"creation_date": "1434557536720",
"number_of_shards": "1",
"number_of_replicas": "0",
"version": {
"created": "1050299"
},
"uuid": "FfQADLGVQVOPV3913exKsw"
}
},
"warmers": {}
}
}
我也尝试进行 JSON 查询,但获得 0 次点击:
GET _search
{
"query" :{
"filtered": {
"query": {
"match_all": { }
},
"filter": {
"bool" : {
"must" : [
{"term" : { "macAddr" : "000A8D810F5A" } },
{"term" : { "insturmentName" : "Amin's furnace" } },
{"term" : { "instrumentAddress" : "8D810F5A"}},
{"term" : { "uhhVersion" : "v2.5"}},
{"term" : { "groupName" : "Amin's Group"}},
{"term" : { "groupNo" : 2}},
{"term" : { "instrType" : 60}}
]
}
}
}
}
}
Response:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 4,
"successful": 3,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
【问题讨论】:
标签: c# .net database elasticsearch nest