2017-08-08 77 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