0

我正在尝试suite_name从 ElasticSearch 中获取所有唯一字段,但我aggs没有返回任何存储桶。

我正在使用这个映射

{
  "functional_tests": {
    "mappings": {
      "web_test_result": {
        "properties": {
          "duration": {
            "type": "long"
          },
          "fail_category": {
            "type": "string"
          },
          "fail_info": {
            "properties": {
              "message": {
                "type": "string"
              },
              "screenshot_url": {
                "type": "string"
              },
              "stack": {
                "type": "string"
              }
            }
          },
          "fail_message": {
            "type": "string"
          },
          "fail_stack": {
            "type": "string"
          },
          "file": {
            "type": "string"
          },
          "finish_time": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis"
          },
          "instance_id": {
            "type": "long"
          },
          "order_number": {
            "type": "long"
          },
          "query": {
            "properties": {
              "term": {
                "properties": {
                  "instance_id": {
                    "type": "long"
                  },
                  "suite_name": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "screenshot_url": {
            "type": "string"
          },
          "size": {
            "type": "long"
          },
          "status": {
            "type": "string"
          },
          "suite_id": {
            "type": "string"
          },
          "suite_title": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },
          "test_id": {
            "type": "string"
          },
          "test_title": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },
          "timedOut": {
            "type": "boolean"
          }
        }
      }
    }
  }
}

和这个aggs

GET functional_tests/web_test_result/_search
{
  "size": 0, 
  "aggs" : {
    "suite_titles" : {
      "terms" : { 
        "field" : "suite_title.raw", 
        "size" : 1000
      }
    }
  }
}

这返回给我这个

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 3383,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "suite_titles": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    }
  }
}

如果我做aggson suite_id,这是一个单一的令牌,我会得到桶。

4

1 回答 1

0

从映射中,您可以验证您的suite_idis 类型string和从 Elasticsearch 的默认映射中它是not_analyzed.

.raw可用于分析的字段,这些字段suite_id.raw将为您提供非分析值并suite_id为您提供分析值。

您没有任何分析值,因此没有.raw字段。你必须suite_id只使用。

于 2016-07-15T04:41:48.963 回答