【发布时间】:2021-01-01 22:23:25
【问题描述】:
使用 elasticsearch 7.1.0 我有这样的对象:
{
... other fields
"entityId": "abcdef",
"anotherParameter": "something@weird-here"
}
我需要对 entityId 和 anotherParameter 进行完全匹配(大小写可以忽略)。 我通过 C# 中的 NEST 库使用此查询
GET objects/_search
{
"from": 0,
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"term": {
"entityId": {
"value": "abcdef"
}
}
},
{
"term": {
"anotherParameter": {
"value": "something@weird-here"
}
}
}
]
}
}
]
}
}
}
不返回任何内容。 这两个字段的映射是:
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
如果我省略 @ 而只是在 anotherParameter 字段中输入“某物”,我会得到正确的对象,但也会得到我不想返回的东西。 我正在寻找有关如何进行精确搜索的说明。有人吗?
【问题讨论】:
标签: elasticsearch