elasticsearch -no mapping found

时间:2017-08-08 09:05:15

标签: elasticsearch kibana

我有一个索引:( Elasticsearch 5.5.1)

PUT myindex
{
  "settings" : {
    "number_of_shards" : 3,
    "number_of_replicas" : 2
  },
  "mappings" : {
    "mymap" : {
      "properties" : {
        "data" : {
          "type": "text"
        }
      }
    }
  }
}

现在,当我执行以下操作时:

GET myindex/_search?q=content:*&filter_path=hits.hits._source.path.real&sort=file.last_modified:desc&size=10

我收到的数据是我期望的数据。

如果我将调用更改为直接针对Elasticsearch工作:

GET localhost:9200/myindex/_search?q=content:*&filter_path=hits.hits._source.path.real&sort=file.last_modified:desc&size=10

它抱怨找不到[file.last_modified]的没有映射以便排序。

为何出现差异?

1 个答案:

答案 0 :(得分:0)

在Kibana的/config/kibana.yml混淆文件中,您有此条目:

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
#server.host: "localhost"

因此,Kibana默认击中此处提供的主机。如果您使用Kibana控制台,则此处配置的主机会自动附加。点击"扳手"按钮和Copy as cURL,您可以查看真正发送给elasticsearch的内容。

例如在Kibana中点击这个:

GET my_index/test/_search

cURL的等价(kibana.yml没有任何变化)是:

curl -XGET "http://localhost:9200/my_index/test/_search"

更新:关键是Kibana已经知道您正在尝试使用localhost,因为它是在kibana.yml中配置的,因此您无法再次放置该网址,因为它会在后台创建GET /localhost:9200/localhost:9200/myindex/_search。当您使用某个REST客户端(如cURL,Postman等)访问elasticsearch时,您可以使用完整的URL。在Kibana,你直接打到索引。

相关问题