我将一个非常旧的ElasticSearch版本切换到6.5版。
...
"text_mined_entities": {
"nlp": {
"abbreviations": [],
"chunks": [],
"recurring_chunks": [],
"tagged_entities_grouped": {
"NEURO|SCICRUNCH": [
{
"category": "NEURO",
"end": 41,
"label": "Infant",
"match": "infant",
"original_value": "Infant",
"reference": "BIRNLEX695",
"reference_db": "SCICRUNCH",
"sentence": 0,
"start": 35
},
...
我想过滤text_mined_entities.nlp.tagged_entities_grouped。*。reference字段(存储为'keyword'),但是运气不好。像这样:
GET _search
{
"query": {
"bool": {
"filter": { "term": {
"text_mined_entities.nlp.tagged_entities_grouped.*.reference": "BIRNLEX695"
}}
}
}
}
有什么建议吗?谢谢。
答案 0 :(得分:0)
字段通配符不能应用于术语查询。相反,您可以使用query_string,它也支持字段上的通配符。因此,以下方法将起作用:
假设text_mined_entities
和nlp
的类型为nested
{
"query": {
"nested": {
"path": "text_mined_entities.nlp",
"query": {
"query_string": {
"query": "BIRNLEX695",
"fields": [
"text_mined_entities.nlp.tagged_entities_grouped.*.reference"
]
}
}
}
}
}
更新(如果text_mined_entities
和nlp
是object
类型而不是nested
):
{
"query": {
"query_string": {
"query": "BIRNLEX695",
"fields": [
"text_mined_entities.nlp.tagged_entities_grouped.*.reference"
]
}
}
}