ElasticSearch过滤具有相同术语的多种文档 [英] ElasticSearch filtering mulitple documents with same term

查看:41
本文介绍了ElasticSearch过滤具有相同术语的多种文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何描述此查询,因此不知道在文档中查找什么.我将尝试用一个虚构的示例进行演示.

I'm not sure how to describe this query so don't know what to look for in the documentation. I will try and demonstrate with a made up example.

您拥有带序列号的电子设备清单"serial":"xyz"

You have an inventory of electronic devices with serial numbers "serial": "xyz"

它们都具有状态,例如

状态":有问题"

状态":已修复"

可以有多个具有相同序列号的文档.例如

There can be multiple documents with the same serial number. E.g.

{"serial":"xyz"状态":有问题"日期":2015年1月1日}

,然后再发送另一个文档

and then another doc at a later date

{"serial":"xyz"状态":已修复"日期":2015年1月2日}

因此,我想搜索索引以显示所有序列号,其中存在状态为故障"的文档和状态为已修复"的文档.该查询的类型是什么?

So i want to search my index to show me all serial numbers where there exists a document with status "faulty" AND a document with status "repaired". What is the type of query for that?

推荐答案

只是好奇地检查此查询是否满足您的需求:

just curious to check if this query satisfies your need:

{
  "query": {
    "query_string": {
      "query": "status:faulty OR status:repaired"
    }
  }
}

这篇关于ElasticSearch过滤具有相同术语的多种文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆