19

このクエリを少し構築しようとしています。私が検索しているインデックスには、ID を持つフィールド「エンティティ」もあります。したがって、いくつかのレコードには、エンティティの ID に応じて、"entity" : 16、"entity" 156 などがあります。このクエリを拡張して、{:term => {:entity => [1, 16, 100]}} などの配列または値のリストを渡して、次のレコードを取得できるようにする必要があります。エンティティ値としてこれらの整数の 1 つ。私は今まで何の運もありませんでした。誰か助けてくれますか?

{ 
  "query" : {

    "bool" : {
      "must" : [
        {
          "term" : {"user_type" : "alpha"}
        }, 
        { 
          "term" :{"area" : "16"}
        }
      ], 
      "must_not" : [], 
      "should" :   []
    }
  }, 
  "filter": {
    "or" : [{
       "and" : [
          { "term" : { "area" : "16" } },
          { "term" : { "date" : "05072013" } }
       ]
    }, {
       "and" : [
          { "term" : { "area" : "16" } },
          { "term" : { "date" : "blank" } }
       ]
    }


    ]
  },
"from" : 0,
"size" : 100 
}
4

1 に答える 1

34

"terms"の代わりに使用し"term"ます。

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html https://www.elastic.co/guide/en/elasticsearch/reference/current/query -dsl-terms-query.html

{ "terms" : { "entity" : [ 123, 1234, ... ] }}

于 2013-04-27T18:35:06.587 に答える