我想做一个ElasticSearch查询,在它的过滤器中获取一个参数,有时这个参数是一个单一的值,有时它是一个值列表,I知道当它是一个单一的值时,我应该使用“术语”,当它是一个列表时,我应该使用“术语”。但我想要一个可以处理这两件事的查询,并将其传递给一个值或一个列表,并返回结果。 [全是一个查询],你有什么想法如何做到这一点?ElasticSearch查询一次过滤一个值和一个值列表
query for single value:
{'filter': {
'and': [
{'term': {'first': 1}},
{'term': {'second': 1}},
]
},
}
查询列表:
{'filter': {
'and': [
{'terms': {'first': [1,2,3]}},
{'terms': {'second': [1,2,3]}},
]
},
}
,但我想一个查询处理两种。