0

このような属性を持つデータがあります

apiUrl:/REST/endpoint/123

ここで、すべての URL を表示したいと思います。集計関数を使用しようとしています (apiUrl.raw はマルチフィールドの not_analyzed 部分です)。

POST /index/type/_search
{
  "aggregations": {
    "application": {
      "terms": {
        "field": "apiUrl.raw"
      }
    }
  }
}

このクエリを実行すると、結果が返されません。私は何を間違っていますか?行に沿って何かを期待します(および発生回数):

  • /REST/api1/123
  • /REST/otherApi/345

ありがとう!

4

1 に答える 1

1

クエリは空でない結果を返します。比較して、違いを教えてください。

PUT index
PUT index/type/_mapping
{
  "properties" : {
    "apiUrl": {
      "type": "multi_field",
      "fields": {
        "apiUrl": {"type":"string", "index":"analyzed"},
        "raw": {"type":"string", "index":"not_analyzed"}
      }
    }
  }
}
GET index/type/_mapping
PUT index/type/1
{
  "apiUrl":"/REST/api1/123"
}
PUT index/type/2
{
  "apiUrl":"/REST/otherApi/345"
}
GET index/type/_search?fields=apiUrl.raw
GET index/type/_search
{
  "aggregations": {
    "application": {
      "terms": {
        "field": "apiUrl.raw"
      }
    }
  }
}

応答:

{
   "took": 76,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 1,
      "hits": [
         {
            "_index": "index",
            "_type": "type",
            "_id": "1",
            "_score": 1,
            "_source": {
               "apiUrl": "/REST/api1/123"
            }
         },
         {
            "_index": "index",
            "_type": "type",
            "_id": "2",
            "_score": 1,
            "_source": {
               "apiUrl": "/REST/otherApi/345"
            }
         }
      ]
   },
   "aggregations": {
      "application": {
         "doc_count_error_upper_bound": 0,
         "sum_other_doc_count": 0,
         "buckets": [
            {
               "key": "/REST/api1/123",
               "doc_count": 1
            },
            {
               "key": "/REST/otherApi/345",
               "doc_count": 1
            }
         ]
      }
   }
}
于 2015-05-06T22:19:53.327 に答える