2016-03-15 50 views
0

我試圖使用elasticsearch-php 2.0,我一直收到錯誤「找不到處理程序找到uri Elasticsearch/Connections/Connection .php:673'「與Elasticsearch 2.2.0。

但我想知道當我試着用Elasticsearch 1.7.5調用同樣的函數時,我可以得到正確的結果。

我根本沒有更改我的代碼,「$ query」完全相同。 有誰知道我該如何解決問題?

array(
    'index' => 'cat_itemnames', 
    'type' => 'category', 
    'id' => '7110', 
    'search_size' => (int) 20, 
    'percent_terms_to_match' => (float) 0.3, 
    'mlt_fields' => array(
     (int) 0 => 'itemnames' 
    ), 
    'body' => array(
     'explain' => true, 
     'query' => array(
      'more_like_this' => array(
       'like_text' => 'drink' 
      ) 
     ) 
    ) 
) 
這裏是日誌在Connection.php

/vendors/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(線672)

「不處理髮現的URI [/ cat_itemnames /類別/ 7110/_mlt?search_size = 20 & percent_terms_to_match = 0.3 & mlt_fields = itemNames中]和方法[GET]」

/vendors/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(線673)

array(
    'transfer_stats' => array(
     'url' => 'http://xxx.xxx.xxx.xxx:9200/cat_itemnames/category/7110/_mlt?search_size=20&percent_terms_to_match=0.3&mlt_fields=itemnames', 
     'content_type' => 'text/plain; charset=UTF-8', 
     'http_code' => (int) 400, 
     'header_size' => (int) 90, 
     'request_size' => (int) 273, 
     'filetime' => (int) -1, 
     'ssl_verify_result' => (int) 0, 
     'redirect_count' => (int) 0, 
     'total_time' => (float) 0.044938, 
     'namelookup_time' => (float) 0.000209, 
     'connect_time' => (float) 0.023181, 
     'pretransfer_time' => (float) 0.023258, 
     'size_upload' => (float) 110, 
     'size_download' => (float) 143, 
     'speed_download' => (float) 3182, 
     'speed_upload' => (float) 2447, 
     'download_content_length' => (float) 143, 
     'upload_content_length' => (float) 110, 
     'starttransfer_time' => (float) 0.044878, 
     'redirect_time' => (float) 0, 
     'redirect_url' => '', 
     'primary_ip' => 'xxx.xxx.xxx.xxx', 
     'certinfo' => array(), 
     'primary_port' => (int) 9200, 
     'local_ip' => '192.168.11.4', 
     'local_port' => (int) 49217, 
     'error' => '', 
     'errno' => (int) 0 
    ), 
    'curl' => array(
     'error' => '', 
     'errno' => (int) 0 
    ), 
    'effective_url' => 'http://xxx.xxx.xxx.xxx:9200/cat_itemnames/category/7110/_mlt?search_size=20&percent_terms_to_match=0.3&mlt_fields=itemnames', 
    'headers' => array(
     'Content-Type' => array(
      (int) 0 => 'text/plain; charset=UTF-8' 
     ), 
     'Content-Length' => array(
      (int) 0 => '143' 
     ) 
    ), 
    'version' => '1.1', 
    'status' => (int) 400, 
    'reason' => 'Bad Request', 
    'body' => 'No handler found for uri [/cat_itemnames/category/7110/_mlt?search_size=20&percent_terms_to_match=0.3&mlt_fields=itemnames] and method [GET]' 
) 

服務器 - >亞馬遜的Linux AMI 2015.09釋放
客戶端 - >蘋果埃爾卡皮坦10.11.3
PHP版本 - 7.0.4
ES-PHP客戶端版本 - 2.0
Elasticsearch版本 - 1.7.5成功 2.2.0失敗

回答

1

More Like This API已在1.6中棄用,並且已被removed in 2.0

因此,您不能再調用/cat_itemnames/category/7110/_mlt端點,這似乎是您正在做的。

您現在應該簡單地使用more_like_this query,然後將其發送到/cat_itemnames/category/_search端點。

+0

謝謝。我沒有閱讀查詢DSL更改頁面。我已經改變它使用搜索,它工作正常。 – k16

+0

真棒,很高興它幫助! – Val

相關問題