elasticsearch 弹性搜索查询,用于生成2个映射的范围,elasticsearch,elasticsearch" /> elasticsearch 弹性搜索查询,用于生成2个映射的范围,elasticsearch,elasticsearch" />

elasticsearch 弹性搜索查询,用于生成2个映射的范围

elasticsearch 弹性搜索查询,用于生成2个映射的范围,elasticsearch,elasticsearch,嗨,我想查询x大于最小租金,x小于最大租金。 这里是映射 'mappings' => [ 'project_listing_v1' => [ 'properties' => [ 'location' => [ 'type' => 'geo_point'

嗨,我想查询x大于最小租金,x小于最大租金。 这里是映射

'mappings' => [
                    'project_listing_v1' => [
                        'properties' => [
                            'location' => [
                                'type' => 'geo_point'

                            ],
                            'min_rent'=>[
                                'type'=>'short',
                            ],
                            'max_rent'=>[
                                'type'=>'short',
                            ]
                        ]

可以将bool查询与must子句一起使用,如下所示:

GET project_listing_v1/_search
{
  "query": {
    "bool": {
      "must": [
       {
          "range": {
            "min_rent": {
              "gt": x
            }
          }
       },
       {
          "range": {
            "max_rent": {
              "lt": x
            }
          }
        }
      ]
    }
  }
}
注意:必须用实际值替换查询中的“x”

有关bool查询的更多信息: