AndyB
Well-known member
Hello,
I'm trying to use the following ElasticSearch API code. For simple queries the ElasticSearch API is working very good, however the following query does not work (returns empty results) when I add the 'range' portion of the code:
The following code using cURL works perfect:
The only difference I can see is the cURL code above uses the square brackets around the 'must' portion of the code.
Any help greatly appreciated.
I'm trying to use the following ElasticSearch API code. For simple queries the ElasticSearch API is working very good, however the following query does not work (returns empty results) when I add the 'range' portion of the code:
PHP:
$dsl['query'] = array(
'filtered' => array(
'query' => array(
'match' => array(
'thread.title' => array(
'query' => $threadTitle,
'operator' => 'or'
)
)
),
'filter' => array(
'bool' => array(
'must' => array(
'term' => array(
'thread.node' => $currentNodeId
),
'range' => array(
'thread.date' => array(
'gt' => $gt
)
)
),
'must_not' => array(
'term' => array(
'thread.discussion_id' => $currentThreadId
)
)
)
)
)
);
$results = XenES_Api::search($indexName, $dsl);
The following code using cURL works perfect:
PHP:
$data_string = '{
"from" : 0, "size" : "' . $maximumResults . '",
"query" : {
"filtered" : {
"query" : {
"match" : {
"thread.title" : {
"query" : "' . $threadTitle . '",
"operator" : "or"
}
}
},
"filter" : {
"bool" : {
"must" : [
{
"term" : {
"thread.node" : "' . $currentNodeId . '"
}
},
{
"range" : {
"thread.date" : {
"gt" : "' . $gt . '"
}
}
}
],
"must_not" : {
"term" : {
"thread.discussion_id" : "' . $currentThreadId . '"
}
}
}
}
}
}
}';
The only difference I can see is the cURL code above uses the square brackets around the 'must' portion of the code.
Any help greatly appreciated.
Last edited: