简体   繁体   English

如何从弹性搜索中获取条件数据

[英]How to get conditional data from elastic search

Currently, my ES data is similar to-目前,我的 ES 数据类似于-

 {
      ..............
      ..............
      "centers" : [

        .................
        .................
        {
          "code" : "ABCA",
          "name": "first_code",
          "level" : 0
        },
        {
          "code" : "XYZX",
          "name": "second_code",
          "level" : 1
        },
        {
          "code" : "XYZX",
          "name": "third_code",
          "level" : -1
        },
        {
          "code" : "QWERTY",
          "name": "fourth_code",
          "level" : 2
        },
        .................
        .................

      ],
      ..............
      ..............

} }

And I want to filter records with the condition like this-我想用这样的条件过滤记录-

filter records where code = "ABCA" and code="XYZX" with additional filter code.level(ABCA) < code.level(XYZX)过滤记录,其中code = "ABCA" 和 code="XYZX"附加过滤器code.level(ABCA) < code.level(XYZX)

Expected O/p:预期的 O/p:

    {
      "code" : "ABCA",
      "name": "first_code",
      "level" : 0
    },
    {
      "code" : "XYZX",
      "name": "second_code",
      "level" : 1
    }

Is this possible?这可能吗?

You need to use the elasticsearch script query in order to achieve it,您需要使用elasticsearch 脚本查询才能实现它,

Please refer this SO answer and this blog for more info and update if still you need help, please show query you tried and would be happy to help further.请参阅此 SO 答案此博客以获取更多信息,如果您仍需要帮助,请进行更新,请显示您尝试过的查询,并很乐意提供进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM