[英]Is there a way to see if a query matches any element in an array in Elasticsearch?
I have this query (eg 'hello') and this id (eg '12345') and I want to search for something that matches both the query in a 'text' field and the id in a 'thread' field. 我有这个查询(例如“ hello”)和这个ID(例如“ 12345”),我想搜索与“文本”字段中的查询和“线程”字段中的ID都匹配的内容。 But the given ids are in an array, so the logic is something like: 但是给定的id在数组中,因此逻辑类似于:
function runThisQuery(query, ids) {
client.search({
index: '_all',
type: 'text',
body: {
query: {
bool: {
must: {
match: { text: query }
},
should: [
{ match: { thread: { query: ids[0], operator: 'AND'} } },
{ match: { thread: { query: ids[1], operator: 'AND'} } }
],
minimum_should_match: 1
}
}
}
})
}
Is there like an $in operator (like in MongoDB) that matches the thread if it's in the 'ids' array? 如果线程在'ids'数组中,是否有匹配线程的$ in运算符(例如在MongoDB中)? Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.