No problem, glad to help! The syntax is definitely kinda gross, I'll try
to write some docs on it soon to help others.
Let me know if you run into any more problems, and feel free to open a
ticket at the Elasticsearch-PHP github repo, I keep a closer eye on tickets
than the mailing list :)
-Z
On Thursday, March 13, 2014 9:37:42 AM UTC-4, Erdal Gunyar wrote:
>
> Hello Zachary,
>
> Thank you for your quick and working responses!
> I've previously tried with double array method and didn't worked, I should
> have missed something at that time.
>
> And thanks also for the object method, didn't know :)
>
> Have a good day all,
>
> Erdal.
>
>
> Le mercredi 12 mars 2014 20:05:11 UTC+1, Zachary Tong a écrit :
>>
>> For the record, this array syntax should work as well:
>>
>> $qry = array(
>> 'query' => array(
>> 'function_score' => array(
>> 'functions' => array(
>> array("script_score" => array('script' =>
>> "doc['boostfield'].value"))
>> ),
>> 'query' => array(
>> 'query_string' => array('query' => 'MyQuery')
>> ),
>> 'score_mode' => 'multiply'
>> )
>> ));
>>
>> But the object notation tends to be safer because it can handle empty
>> objects (for example, a random function without a seed is just
>> `"random_score" : {}`, which will break the array notation. Objects make
>> sure that doesn't happen.
>>
>>
>> On Wednesday, March 12, 2014 2:47:00 PM UTC-4, Erdal Gunyar wrote:
>>>
>>> Hi everybody,
>>>
>>> Does anyone here successfully implemented function_score with
>>> elasticsearch-php?
>>> Of course, without passing all the body as a JSON string.
>>>
>>> I've actually tried but it failed, it looks like it's impossible to pass
>>> the "array+object" located in the "functions" part :
>>> "query": {
>>> "function_score": {
>>> "query": {
>>> "query_string": {
>>> "query": "MyQuery",
>>> }
>>> },
>>> "functions": [{
>>> "script_score": {
>>> "script": "doc['boostfield'].value"
>>> }
>>> }],
>>> "score_mode": "multiply"
>>> }
>>> },
>>>
>>> Any help will be appreciated! :)
>>>
>>> Thanks,
>>>
>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/6d868de2-1c3e-4f4b-abfa-d8fc45e8cd67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.