2016-10-27 1 views
0

나는 elasticsearch와 오류를했습니다있어 :예상 [END_OBJECT]하지만 [FIELD_NAME]

"query_parsing_exception을 : 예상 [END_OBJECT] 만 가지고 [FIELD_NAME], 아마도 너무 많은 쿼리 절"

$search = [ 
      'index' => $this->getParameter('elastic_search')['index'], 
      'type' => 'profile', 
      'body' => [ 
       'query' => [ 
        'bool' => [ 
         'must' => [ 
          'range' => [ 
           'address.latitude' => [ 
            'gte' => $offer->getAddress()->getLatitude() - 0.05, 
            'lte' => $offer->getAddress()->getLatitude() + 0.05, 
           ], 
           'address.longitude' => [ 
            'gte' => $offer->getAddress()->getLongitude() - 0.05, 
            'lte' => $offer->getAddress()->getLongitude() + 0.05, 
           ], 
           'budget' => [ 
            'gte' => $offer->getPrice() - 100, 
            'lte' => $offer->getPrice() + 100, 
           ], 
          ], 
          'bool' => [ 
           "term" => [ 
            "type" => 1 
           ] 
          ] 
         ] 
        ] 
       ], 
       'from' => $request->get('start', 0), 
       'size' => $request->get('limit', 4), 
       'sort' => [], 
       '_source' => ['exclude' => 'user'], 
      ] 
     ]; 

문제가 무엇하시기 바랍니다 있습니다 : 내가 PHP와 elasticsearch 사용

이 내 검색입니까?

답변

2

range 쿼리는 자체 배열 요소에 있어야하며 모든 bool/must 쿼리는 배열로 묶어야합니다. 다음과 같이 할 수 있습니다.

$search = [ 
     'index' => $this->getParameter('elastic_search')['index'], 
     'type' => 'profile', 
     'body' => [ 
      'query' => [ 
       'bool' => [ 
        'must' => [ 
         [ 
         'range' => [ 
          'address.latitude' => [ 
           'gte' => $offer->getAddress()->getLatitude() - 0.05, 
           'lte' => $offer->getAddress()->getLatitude() + 0.05, 
          ] 
         ] 
         ], 
         [ 
         'range' => [ 
          'address.longitude' => [ 
           'gte' => $offer->getAddress()->getLongitude() - 0.05, 
           'lte' => $offer->getAddress()->getLongitude() + 0.05, 
          ], 
         ], 
         ], 
         [ 
         'range' => [ 
          'budget' => [ 
           'gte' => $offer->getPrice() - 100, 
           'lte' => $offer->getPrice() + 100, 
          ], 
         ], 
         ], 
         [ 
          "term" => [ 
           "type" => 1 
          ] 
         ] 
        ] 
       ] 
      ], 
      'from' => $request->get('start', 0), 
      'size' => $request->get('limit', 4), 
      'sort' => [], 
      '_source' => ['exclude' => 'user'], 
     ] 
    ]; 
+0

이 모든 행운을 빕니다. – Val