Does the PHP client support this? Are there any examples of using an indexed script within the query request? All the examples in documentation I can find are inline.
Code
$scriptScore = new \stdClass();
$scriptScore->script = "return _score";
$query = array(
'function_score' => array(
'functions' => array(
array("script_score" => $scriptScore)
),
'query' => $query_string,
'score_mode' => 'sum',
'boost_mode' => 'replace'
)
);
$params['body']['query'] = $query;
The above inline script works and the query results are returned.
However using a similar method for an indexed script does not work:
$scriptScore = new \stdClass();
$scriptScore->script->id = "indexedScript";
$scriptScore->script->lang = "groovy";
$query = array(
'function_score' => array(
'functions' => array(
array("script_score" => $scriptScore)
),
'query' => $query_string,
'score_mode' => 'sum',
'boost_mode' => 'replace'
)
);
$params['body']['query'] = $query;
$query_string is set to bool, with match and should queries.
The ES cluster does have all indexed scripts enabled.
I'm using v. 1.7.5, php v. 5.6