hi !
the query below is working but when i use the php official client but i
still have the exception : malformed query, expected a START_OBJECT
"query": {
"function_score": {
"query": {
"terms": {
"categoryName": [
"toto",
"tutu"
],
"minimum_match": 1
}
},
"functions": [
{
"filter": {
"terms": {
"tags": [
"truc",
"bidule"
]
}
},
"boost_factor": 2
}
]
}
}
in my script the query is divided
both $category and $boost are arrays of values
// function_score --> init main query
$functionScoreQuery = array( 'query' => array(
'terms' => array(
'categoryName' => $category
)
));
// function_score functions --> init boost
$functionScoreFunctions = array( 'functions' => array(
'filter' => array(
'terms' => array(
'tags' => $boost
)
),
'boost_factor' => 2
));
$defaultSubQuery['function_score'] = $functionScoreQuery;
if (($boost)) {
$defaultSubQuery['function_score'] +=
$functionScoreFunctions;
}
a print_r() of the request show :
Array
(
[index] => myIndex
[body] => Array
(
[query] => Array
(
[function_score] => Array
(
[query] => Array
(
[terms] => Array
(
[categoryName] => Array
(
[0] => toto
[1] => tutu
)
)
)
[functions] => Array
(
[filter] => Array
(
[terms] => Array
(
[tags] => Array
(
[0] => truc
[1] => bidule
)
)
)
[boost_factor] => 2
)
)
)
[from] => 0
[size] => 10
)
--> function_score: malformed query, expected a START_OBJECT while parsing
functions but got a FIELD_NAME];
I know the function_score as a special syntax combining arrays and
objects
(http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_search_operations.html
)
but i didn' found the correct syntax using the official php client
...examples are quite light in this case so any help will be appreciated
regards,
chris
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/68c9c8b4-96f4-46a0-bf45-6f29693991a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.