ES-5.0.0 with php client query error

Hi I indexed mysql data on ES-5.0.0 and I did query PHP:

unset($AlimSekli);
    if(isset($_GET['AlimSekli'])){
        $AlimSekli['match_phrase']['AlimSekli']=$_GET['AlimSekli'];
    }

if(is_array($AlimSekli)){
    $searchParams['body']['query']['bool']['should']['and'][]=$AlimSekli;
}

but I have error:

Fatal error:  Uncaught exception 
'Elasticsearch\Common\Exceptions\BadRequest400Exception' with message 
'{"error":{"root_cause":[{"type":"parsing_exception","reason":"[and] 
query malformed, no start_object after query 
name","line":1,"col":35}],"type":"parsing_exception","reason":"[and] 
query malformed, no start_object after query 
name","line":1,"col":35},"status":400}' in 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:681
Stack
 trace:
#0 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(659):
 Elasticsearch\Connections\Connection->tryDeserializeError(Array, 
'Elasticsearch\\C...')
#1 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(579):
 Elasticsearch\Connections\Connection->tryDeserialize400Error(Array)
#2 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticse
 in /home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 682

No idea until you print the JSON document which is sent to elasticsearch.
Can you do that?

Ok .

curl -XGET 'localhost:9200/titub2/ihale/_search' -d '{
    "query" : {
        "match" : {
            "AlimSekli" : "DOGRUDAN"
        }
    }
}'

result:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/titub2/ihale/_search]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/titub2/ihale/_search]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

Don't you notice something in the response here?

And I don't believe that 'body']['query']['bool']['should']['and'] generates

"query" : {
        "match" : {
            "AlimSekli" : "DOGRUDAN"
        }
    }
unset($AlimSekli);
    if(isset($_GET['AlimSekli'])){
        $AlimSekli['match_phrase']['AlimSekli']=$_GET['AlimSekli'];
    }


if(is_array($AlimSekli)){
    $searchParams['body']['query']['match'][]=$AlimSekli;
} 

I tried http://192.168.1.35/filtreleme.php?AlimSekli=DOGRUDAN and result:

Fatal error:  Uncaught exception 
'Elasticsearch\Common\Exceptions\BadRequest400Exception' with message 
'{"error":{"root_cause":[{"type":"parsing_exception","reason":"[match] 
query malformed, no start_object after query 
name","line":1,"col":19}],"type":"parsing_exception","reason":"[match] 
query malformed, no start_object after query 
name","line":1,"col":19},"status":400}' in 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:681
Stack
 trace:
#0 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(659):
 Elasticsearch\Connections\Connection->tryDeserializeError(Array, 
'Elasticsearch\\C...')
#1 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(579):
 Elasticsearch\Connections\Connection->tryDeserialize400Error(Array)
#2 
/home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elast
 in /home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 682

I can't tell if you don't answer my question. Sorry.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.