k16
k16

Reputation: 481

elasticsearch-php 2.0 $client->mlt($query) returns "No handler found for uri"

I tried to use elasticsearch-php 2.0 and I have been getting the error "No handler found for uri Elasticsearch/Connections/Connection.php:673'" with Elasticsearch 2.2.0.

But I wonder when I tried to call same function with Elasticsearch 1.7.5, I can get the correct result.

I didn't change my code at all, and the "$query" is completely same. Does anyone know how can I solve the problem ?

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'
            )
        )
    )
)
And here is logs at Connection.php

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

'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]'

/vendors/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php (line 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]'
)

Server -> Amazon Linux AMI 2015.09-release
Client -> Mac El Capitan 10.11.3
PHP Version - 7.0.4
ES-PHP client version - 2.0
Elasticsearch version - 1.7.5 Success 2.2.0 Fail

Upvotes: 0

Views: 458

Answers (1)

Val
Val

Reputation: 217324

The More Like This API was deprecated in 1.6 and has been removed in 2.0.

As a result, you cannot call the /cat_itemnames/category/7110/_mlt endpoint anymore, which seems to be what you're doing.

You should now simply use a more_like_this query and send it to the /cat_itemnames/category/_search endpoint instead.

Upvotes: 1

Related Questions