2016-03-15 51 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

相关问题