Resolved
I am trying to get a results back using the official elasticsearch 5.0 php package. I can get the desired results via URL and cURL.
http://localhost:9200/index/doctype/_search?q=status:available
I get 8 hits and 8 hit results, as expected.
curl -XGET 'localhost:9200/index/doctype/_search?pretty' -d'
{
"query" : {
"term" : { "status" : "available" }
}
}'
I get 8 hits and 8 hit results, as expected.
Using the following various bits of code, I get 8 results but 0 hits.
$params['body']['query']['term']['status'] = 'available';
$params['q'] = 'status:available';
$params['body'] = [
'query' => [
'bool' => [
'must' => [
['match' => ['status' => 'available']],
]
]
]
];
Called via:
$params = [
'index' => 'index',
'type' => 'doctype',
];
$skip = !empty($_GET['page']) ? (int)$_GET['page'] - 1 : 0;
$listings_per_page = 25;
$params['from'] = $skip * $per_page;
$params['size'] = $per_page;
// show only available
$params['body'] = [
'query' => [
'bool' => [
'must' => [
['match' => ['status' => 'available']],
]
]
]
];
$hosts = [env('ES_HOST', 'elasticsearch') . ':' . env('ES_PORT', '9200')];
$client = ClientBuilder::create()->setHosts($hosts)->build();
$es_results = $client->search($params);
I have the index and doctype set properly in the $params as well in other bits of code. What could I be doing wrong here?
$params['size'] = 10to your code?fromhas a value higher than 8 and that's the reason why you don't see any hits. Can you print out the value offromandsize?