Groups
Groups
Sign in
Groups
Groups
Elastica - Elasticsearch PHP Client
Conversations
About
Send feedback
Help
Script Based Sorting
959 views
Skip to first unread message
S.K. Asgarov
unread,
Mar 6, 2012, 6:07:23 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Elastica - Elasticsearch PHP Client
Hi, help me pls, how can i use Script Based Sorting (http://
www.elasticsearch.org/guide/reference/api/search/sort.html
)?
This code
$sort = array(
"script" => "doc[tstamp].value * 2"
);
return me an earchPhaseExecutionException[Failed to execute phase
[query], total failure; Isn't it right?
ruflin
unread,
Mar 6, 2012, 6:54:02 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elastica-...@googlegroups.com
Please try
$sort = array(
'_script' => array('script' ' ....'));
I have never tried it, but this should work.
S.K. Asgarov
unread,
Mar 6, 2012, 7:02:58 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Elastica - Elasticsearch PHP Client
$sort = array(
'_script' => array('script' => 'doc[tstamp].value * 2')
);
$query->addSort($sort);
didn't work =( same exception
Nicolas Ruflin
unread,
Mar 6, 2012, 7:08:31 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elastica-...@googlegroups.com
Ok, I see two options for this.
1. You write a test
2. You do it the old way and post what the output for the following is:
print_r($query->toArray());
Then we should see if the structure matches the one from elasticsearch.
--
@
ruflin
useKit.com
Xodoa.com
Ruflin.com
Message has been deleted
S.K. Asgarov
unread,
Mar 6, 2012, 8:34:01 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Elastica - Elasticsearch PHP Client
Here's print_r
array(2) {
["query"] => array(1) {
["term"] => array(1) {
[100000] => string(6) "100000"
}
}
["sort"] => array(1) {
[0] => array(1) {
["_script"] => array(1) {
["script"] => string(23) "doc['tstamp'].value * 2"
}
}
}
}
May be problem in '[0] => array(1) {'?
> smime.p7s
> 4KViewDownload
ruflin
unread,
Mar 6, 2012, 8:42:41 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elastica-...@googlegroups.com
Ah, I see the issue. You are using addSort instead of addSort. Please try it again.
S.K. Asgarov
unread,
Mar 6, 2012, 8:59:43 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Elastica - Elasticsearch PHP Client
Oh, yes! It's works! Thank u very much, i love u!
Here's working example
$sort = array(
"_script" => array(
'script' => "doc['field_name'].value * 2",
'type' => 'number'),
);
$query->setSort($sort);
Nicolas Ruflin
unread,
Mar 6, 2012, 9:00:09 AM
3/6/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elastica-...@googlegroups.com
You're welcome.
--
@
ruflin
useKit.com
Xodoa.com
Ruflin.com
Reply all
Reply to author
Forward
0 new messages