Some pseudo-ish code using the Java API: SearchRequestBuilder builder = ...
SortBuilder sortBuidler = org.elasticsearch.search.sort.fieldSort(field); builder.setTrackScores(true); builder.addSort(sortBuidler); builder.addSort(scoreSort().order(SortOrder.DESC)); Hope this helps, Ivan On Tue, Jan 21, 2014 at 10:47 PM, Mukul Gupta <[email protected]> wrote: > Hi Ivan, > > Actually my code is in java. I have seen those links but not able to > implement it in my code. I'm using customscorequerybuilder for building my > query. How can I use this sort in my code. Is there any java api for this ? > Also, Can I do this sort in my mapping itself ? > > Thanks > > > On Wed, Jan 22, 2014 at 3:22 AM, Ivan Brusic <[email protected]> wrote: > >> You can sort on multiple fields for tie-breakers: >> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html >> >> If you are first sorting on a field, and not the score, you will need to >> enable track_scores: >> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores >> >> Cheers, >> >> Ivan >> >> >> On Tue, Jan 21, 2014 at 1:30 AM, coder <[email protected]> wrote: >> >>> Hi, >>> >>> I want to configure the ElasticSearch so that it after calculating the >>> score of each document corresponding to a user query, it sorts those score >>> documents by some other field and then give the response. There may be a >>> case in which some documents have same score. I want Elasticsearch to sort >>> those same scoring documents on some other field. That's why needed this >>> functionality. Can anyone tell me how can I add this functionality to my >>> mapping ? >>> >>> 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/cc1f83fb-c00e-4b71-8e12-5b2c096714d0%40googlegroups.com >>> . >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> 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/CALY%3DcQCf3YsAYXqMR_2S3p3Naw-mKZv7iPr9sW%3D37hzHsWHMvA%40mail.gmail.com >> . >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > 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/CAAVTvp44q9tj_mvgbVqVUcXnY7QQZg9jSFj85ZsYf%3D-ME%3DGgjw%40mail.gmail.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CALY%3DcQDrh%3D3Spe1ucfLzrK%2B9QQ6brhQ4_M2gYVdGaa-ZnjkhYw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
