弹性搜索中[bool]中START_OBJECT的未知键

时间:2017-12-12 13:15:14

标签: elasticsearch elasticsearch-5

Elasticsearch在Elasticsearch中提供了类似Unknown key for a START_OBJECT in [bool]的错误。

我的查询如下:已更新

var searchParams = {
  index: 'offers',
  body:{
    query:{
    bool : {
      must : {
        query: {
            multi_match: {
                  query: query,
                  fields:['title','subTitle','address','description','tags','shopName'],
                  fuzziness : 'AUTO'
            }
        }
      },
      filter : {
            geo_distance : {
                distance : radius,
                location : {
                    lat : latitude,
                    lon : longitude
                }
            }
        }
    }}},
  filter_path :'hits.hits._source',
  pretty:'true'
};

有人能告诉我如何在弹性搜索中混合使用地理和模糊搜索查询吗?

1 个答案:

答案 0 :(得分:8)

body应如下所示(您错过了query部分):

  body:{
   query: {        <--- add this
    bool : {
      must : {
          multi_match: {
                query: query,
                fields:['title','subTitle','address','description','tags','shopName'],
                fuzziness : 'AUTO'
          }
      },
      filter : {
            geo_distance : {
                distance : radius,
                location : {
                    lat : latitude,
                    lon : longitude
                }
            }
        }
    }}},