2016-12-23 3 views
-1

特定のフィールドに一意の値を取得するために、Elastic検索でクエリがあります。 where節を使用して一意の値を取得する方法。 XYZ、フィールド2:YZXなど弾性agfregationsはuniq値を取得します。where節

{ 
"size": 20, 
"aggs" : { 
    "pf" : { 
     "terms" : { "field" : "platform" } 
    } 
}} 

答えて

0

私はあなたがフィルタの更新のための

{ 
    "size":0, // <-- If you are using ES 2.0 or above, setting size=0 will only return aggregations and no results 
    "query": { 
     "filtered": { 
      "query": { 
       "match_all": {} 
      }, 
      "filter": { 
       "bool": { 
        "must": [{ 
         "term": { 
          "field1": "xyz" 
         } 
        }, { 
         "term": { 
          "field2": "abc" 
         } 
        }] 
       } 
      } 
     } 
    }, 
    "aggregations": { 
     "pf": { 
      "terms": { 
       "field": "platform" 
      } 
     } 
    } 
} 
+0

おかげで集計を探していると思うフィールド1 。もう少し小さな質問があります。固有のプラットフォーム分野を取得しながら、私はすべてのドキュメントも取得しています。プラットフォームの値だけを取得して応答時間を短縮する方法 – venkat

+0

それを入手しました。ありがとうございます – venkat

+0

@venkat、あなたの懸念を解決する場合は、答えを受け入れてください。 – Rahul

関連する問題