elasticsearch-php 2.0 $ client-> mlt($ query)返回"找不到uri"

时间:2016-03-15 04:26:20

标签: elasticsearch

我尝试使用elasticsearch-php 2.0并且我一直收到错误"找不到uri Elasticsearch / Connections / Connection.php的处理程序:673'"使用Elasticsearch 2.2.0。

但我想知道当我试图用Elasticsearch 1.7.5调用相同的函数时,我可以得到正确的结果。

我根本没有改变我的代码,并且" $查询"是完全一样的。 有谁知道如何解决这个问题?

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'
            )
        )
    )
)
这是Login.php的日志

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

'找不到uri [/cat_itemnames/category/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-发布
客户 - > Mac El Capitan 10.11.3
PHP版 - 7.0.4
ES-PHP客户端版本 - 2.0
Elasticsearch版本 - 1.7.5成功                              2.2.0失败

1 个答案:

答案 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端点。