2017-01-14 2 views
2

ジオロケーションフィルタを実行し、ネストされたドキュメントで一致するelasticsearchクエリを実行しようとしていますが、ネストされたクエリを追加するたびにこのエラーが発生します。elasticsearchクエリで何が問題になっていますか?

"[ブール]不正な形式のクエリ、[END_OBJECT]期待が、[FIELD_NAME]が見つかり"

{ 
    "sort": [ 
    { 
     "_score": { 
     "order": "desc" 
     } 
    } 
    ], 
    "query": { 
    "bool": { 
     "filter": { 
     "geo_distance": { 
      "distance": "10km", 
      "geolocation": [ 
      -73.980090948125, 
      40.747844918436 
      ] 
     } 
     }, 
     "must": { 
     "multi_match": { 
      "query": "New York", 
      "fields": [ 
      "name^2", 
      "city", 
      "state", 
      "zip" 
      ], 
      "type": "best_fields" 
     } 
     } 
    }, 
    "nested": { 
     "path": "amenities", 
     "query": { 
     "bool": { 
      "must": [ 
      { 
       "match": { 
       "amenities.name": "Pool" 
       } 
      } 
      ] 
     } 
     } 
    } 
    }, 
    "aggs": { 
    "reviews": { 
     "nested": { 
     "path": "reviews" 
     }, 
     "aggs": { 
     "avg_rating": { 
      "avg": { 
      "field": "reviews.rating" 
      } 
     } 
     } 
    } 
    } 
} 

答えて

4

あなただけnestedクエリを紛失した、このようにしてみてください:

{ 
    "sort": [ 
    { 
     "_score": { 
     "order": "desc" 
     } 
    } 
    ], 
    "query": { 
    "bool": { 
     "filter": { 
     "geo_distance": { 
      "distance": "10km", 
      "geolocation": [ 
      -73.980090948125, 
      40.747844918436 
      ] 
     } 
     }, 
     "must": [ 
     { 
      "multi_match": { 
      "query": "New York", 
      "fields": [ 
       "name^2", 
       "city", 
       "state", 
       "zip" 
      ], 
      "type": "best_fields" 
      } 
     }, 
     { 
      "nested": { 
      "path": "amenities", 
      "query": { 
       "match": { 
       "amenities.name": "Pool" 
       } 
      } 
      } 
     } 
     ] 
    } 
    }, 
    "aggs": { 
    "reviews": { 
     "nested": { 
     "path": "reviews" 
     }, 
     "aggs": { 
     "avg_rating": { 
      "avg": { 
      "field": "reviews.rating" 
      } 
     } 
     } 
    } 
    } 
} 
+0

ああ...それはばかげていた。ありがとう:) – user3791980

+0

クール、喜んでそれが助け! – Val

関連する問題