4

elasticsearch Java High Level REST Client 7.15 实现复杂搜索

 3 years ago
source link: https://www.oschina.net/question/2303434_2324363
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

elasticsearch Java High Level REST Client 7.15 实现复杂搜索

码上中国博客 发布于 今天 13:07

我在使用elasticsearch Java High Level REST Client 7.15 实现一个搜索的时候遇到了问题

有一个业务场景如下:

在es的一个index中的对象结构如下:

[
  {
  "name":"....",
  "age":"....",
  "citys": [
    {
       "cityCode":"43434",
       "order": 1
    },
    {
       "cityCode":"33223",
       "order": 2
    },
    {
       "cityCode":"685656",
       "order": 3
    }
    .....
   ]
  },
  {
  "name":"....",
  "age":"....",
  "citys": [
    {
       "cityCode":"233323",
       "order": 1
    },
    {
       "cityCode":"55443",
       "order": 2
    },
    {
       "cityCode":"78787",
       "order": 3
    }
    .....
   ]
  }

]

查询条件为cityCode1 , cityCode2,我想达到如下搜索效果

1、在包含cityCode1 , cityCode2的对象才能被查出来

2、查询的结果中每个对象的cityCode1的order必须小于cityCode2的order

我不知道该如何构建查询条件才能达到上面的要求,请各位前辈指点迷津。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK