elasticsearch - 未找到映射
elasticsearch -no mapping found
我有一个索引:(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] 的映射以便排序。
为什么会出现差异?
在 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 的控制台,这里配置的主机会自动附加。通过单击 "wrench" 按钮和 Copy as cURL
,您可以检查真正发送到 elasticsearch 的内容。
例如在 Kibana 中点击这个:
GET my_index/test/_search
cURL 的等价物(在 kibana.yml
中没有任何变化)是:
curl -XGET "http://localhost:9200/my_index/test/_search"
Update: 关键是Kibana已经知道你正在访问本地主机因为它是在kibana.yml
中配置的,所以你不能把url 再次因为在后台它会创建 GET /localhost:9200/localhost:9200/myindex/_search
。当您使用某些 REST 客户端(如 cURL、Postman 等)访问 elasticsearch 时,您使用 full url。在 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] 的映射以便排序。
为什么会出现差异?
在 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 的控制台,这里配置的主机会自动附加。通过单击 "wrench" 按钮和 Copy as cURL
,您可以检查真正发送到 elasticsearch 的内容。
例如在 Kibana 中点击这个:
GET my_index/test/_search
cURL 的等价物(在 kibana.yml
中没有任何变化)是:
curl -XGET "http://localhost:9200/my_index/test/_search"
Update: 关键是Kibana已经知道你正在访问本地主机因为它是在kibana.yml
中配置的,所以你不能把url 再次因为在后台它会创建 GET /localhost:9200/localhost:9200/myindex/_search
。当您使用某些 REST 客户端(如 cURL、Postman 等)访问 elasticsearch 时,您使用 full url。在 Kibana 中你直接点击索引。