2017-08-08 66 views
0

我有一个索引:(Elasticsearch 5.5.1)elasticsearch -no映射发现

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]没有映射。

为什么这种差异?

+0

第一个要求是Kibana? – aclokay

+0

@aclokay我使用Kibana作为我的测试工具,但是我想将它移除到我的应用程序,并直接调用Elastic。我需要改变以使它与Elastic一起使用? – bilpor

回答

0

在Kibana的/config/kibana.yml configaration文件,你有这样的条目:

# 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 

与卷曲的quivalent(没有kibana.yml任何变化)是:

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

更新:问题的关键是,Kibana已经知道你打到本地主机,因为它配置在kibana.yml,所以你不能再次把网址,因为在后台它会创建GET /localhost:9200/localhost:9200/myindex/_search。当你使用一些REST客户端(比如cURL,邮差等)进行elasticsearch时,你可以使用完整的URL。在Kibana中,你直接打到索引。

+0

如果我改变我的电话为'GET localhost:9200/myindex/_search?q = content:*'我没有收到任何数据。在Kibana我做 – bilpor

+0

@bilpor - 我更新了我的答案。 – Joanna

+0

啊.....所以我需要使用类似邮递员的东西来证明通过本地主机的呼叫:9200 – bilpor