如何找出我在弹性搜索中排序的索引是什么?

时间:2018-03-12 13:38:43

标签: elasticsearch elasticsearch-6

我使用命令:

在elasticsearch(v6)中创建了新索引
curl -XPUT -H 'Content-Type: application/json' http://localhost:9200/sorttest -d '
{
    "settings" : {
        "index" : {
            "sort.field" : ["username", "date"], 
            "sort.order" : ["asc", "desc"] 
        }
    },
    "mappings": {
        "_doc": {
            "properties": {
                "username": {
                    "type": "keyword",
                    "doc_values": true
                },
                "date": {
                    "type": "date"
                }
            }
        }
    }
}
'

回应是

{"acknowledged":true,"shards_acknowledged":true,"index":"sorttest"}

接下来,我检查了生成的映射

curl -XGET localhost:9200/sorttest/_mapping?pretty

结果是

{
  "sorttest" : {
    "mappings" : {
      "_doc" : {
        "properties" : {
          "date" : {
            "type" : "date"
          },
          "username" : {
            "type" : "keyword"
          }
        }
      }
    }
  }
}

问题是:如何找出为我的索引设置的排序类型?

1 个答案:

答案 0 :(得分:1)

只是

curl -XGET localhost:9200/sorttest?pretty

你会看到:

"settings" : {
  "index" : {
    ...
    "sort" : {
      "field" : [
        "username",
        "date"
      ],
      "order" : [
        "asc",
        "desc"
      ]
    },
    ...
  }
}