2017-09-20 16 views
0

私は以下のように同じクエリで2点を検索しようとしています。 が結果を返します。弾性検索とbool/filterの組み合わせクエリ

"query": { 
      "bool": { 
       "must": { 
        "match_all": {} 
       }, 
       "filter": [{ 
        "geo_shape": { 
         "border": { 
          "shape": { 
           "type": "point", 
           "coordinates": [longitude1, latitude1] 
          }, 
          "relation": "intersects" 
         } 
        } 
       }, { 
        "geo_shape": { 
         "border": { 
          "shape": { 
           "type": "point", 
           "coordinates": [longitude2, latitude2] 
          }, 
          "relation": "intersects" 
         } 
        } 
       } 
       ] 
      } 

     } 

クエリは一度に1ポイントしか動作しません。

一度に2つのポイントを検索するにはどうすればよいですか?

+0

を私はまた、クエリ・ブロック内の2つのブールクエリを試してみました。それも空です –

+0

両方の点が一致する必要がありますか、どちらか一方のみ必要ですか? – Val

+0

結果はORである必要があります。あるポリゴン上の1つの点と別のポリゴン内の1つの点がある場合、クエリは両方のポリゴンIDを返す必要があります。同じポリゴンクエリ内にある場合、同じIDまたは1を持つ2つの結果を返すことができます。 –

答えて

1

あなたが必要とするか、または動作した場合、ヨーヨーuneedではなくbool/shouldを使用します

"query": { 
     "bool": { 
      "should": [{    <--- change this 
       "geo_shape": { 
        "border": { 
         "shape": { 
          "type": "point", 
          "coordinates": [longitude1, latitude1] 
         }, 
         "relation": "intersects" 
        } 
       } 
      }, { 
       "geo_shape": { 
        "border": { 
         "shape": { 
          "type": "point", 
          "coordinates": [longitude2, latitude2] 
         }, 
         "relation": "intersects" 
        } 
       } 
      } 
      ] 
     } 

    } 
+0

ありがとうございます。 ....... –

+0

クール、嬉しい助け! – Val