2

elastic4s を使用して _source の下のすべてのフィールド名 (値ではない) を取得する方法は? マップされたすべてのフィールドのリストが必要です。私は次のようなことをしてみました:

search in indexName / indexType sourceInclude "_source" limit q.limit aggregations(
                aggregation terms "agg0" field "_field_names"  size 0

              )

あるいは

 search in indexName / indexType sourceInclude "_source" sourceExclude ("_all", "_type",
                "_uid", "_version", "_index", "_score", "_id")  limit q.limit aggregations(
                aggregation terms "agg0" field "_field_names"  size 0

              )

しかし、それはしませんでした。_source の下のメタデータ フィールドだけでなく、すべてのメタデータ フィールドを取得しました

"aggregations" : {
    "agg0" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [ {
        "key" : "_all",
        "doc_count" : 1500
      }, {
        "key" : "_source",
        "doc_count" : 1500
      }, {
        "key" : "_type",
        "doc_count" : 1500
      }, {
        "key" : "_uid",
        "doc_count" : 1500
      }, {
        "key" : "_version",
        "doc_count" : 1500
      }
.. more fields 

====更新===

私はこの方法を見つけました:

val map = getMapping indexName /indexType}
val y = map.get("properties").asInstanceOf[java.util.Map[String, _]]
y.keys.toList

同じ結果を得るためのより良い方法はありますか?

4

1 に答える 1

1

Get Mapping API を使用する

GET /index/_mapping
GET /index/_mapping/type

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html

またはクラスター API を使用する

GET /_cluster/state

フィールドリスト :

json -> metadata -> indices -> your_index -> mapping
于 2017-01-11T01:59:05.813 に答える