Sort Doubt

{
"from" : 0, "size" :10,
"fields" :["id","co","prd","pd","st","int","ab","cls","pt"],
"query" : {"query_string":
{

"query": "((test) AND ( (test1) OR (test2))) OR (test)"}},
"facets": {
"tagid": {
"terms": {
"field": ["tagid"],"size": 100 }
}
}}

This Query is working fine..But it return value Order By rank desc..I Don't
need like that.. I need the Result Order by "Or" condition Success...Is It
Possible?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

On Wednesday, February 20, 2013 8:17:05 PM UTC+8, Maria John Franklin wrote:

{
"from" : 0, "size" :10,
"fields" :["id","co","prd","pd","st","int","ab","cls","pt"],
"query" : {"query_string":
{

"query": "((test) AND ( (test1) OR (test2))) OR (test)"}},
"facets": {
"tagid": {
"terms": {
"field": ["tagid"],"size": 100 }
}
}}

This Query is working fine..But it return value Order By rank desc..I
Don't need like that.. I need the Result Order by "Or" condition
Success...Is It Possible?

Result Should be like this

  1. ((test) AND ( (test1) OR (test2)) First this condition result
  2. OR (test) Next this Result

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

You can sorta do this with boosting, where you artificially boost the
"first query" so that it shows above the "second" query. There may be a
few oddities (e.g. a highly relevant "second" query may score higher than a
poorly relevant "first" query, even with boosting), but it should probably
get you 90% there. Disclaimer I have not tried any of these queries and
I'm not entirely certain they will work. Buyer beware =)

Alternatively, you could always run two queries and combine the results in
your application code

First method, inline boosting with Query_String:
{
"query":{
"query_string":{
"query":"((test^5) AND ( (test1^5) OR (test2^5))) OR (test)"
}
}
}

Second method, same idea but uses custom_boost_factor to artificially
inflate the first query.

{
"query":{
"bool":{
"must":{},
"must_not":{},
"should":[
{
"custom_boost_factor":{
"query":{
"query_string":{
"query":"((test) AND ( (test1) OR (test2)))"
}
},
"boost_factor":5
}
},
{
"query_string":{
"query":"test"
}
}
]
}
}
}

If you don't need a strict delineation between results and can allow them
to mix a bit, this is probably a better query:
{
"query":{
"bool":{
"must":{
"query_string":{
"query":"test"
}
},
"must_not":{},
"should":{
"custom_boost_factor":{
"query":{
"query_string":{
"query":"((test1) OR (test2)))"
}
},
"boost_factor":2
}
},
"minimum_number_should_match" : 0
}
}
}

-Zach

On Wednesday, February 20, 2013 7:17:05 AM UTC-5, Maria John Franklin wrote:

{
"from" : 0, "size" :10,
"fields" :["id","co","prd","pd","st","int","ab","cls","pt"],
"query" : {"query_string":
{

"query": "((test) AND ( (test1) OR (test2))) OR (test)"}},
"facets": {
"tagid": {
"terms": {
"field": ["tagid"],"size": 100 }
}
}}

This Query is working fine..But it return value Order By rank desc..I
Don't need like that.. I need the Result Order by "Or" condition
Success...Is It Possible?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

On Wednesday, February 20, 2013 8:17:05 PM UTC+8, Maria John Franklin wrote:

{
"from" : 0, "size" :10,
"fields" :["id","co","prd","pd","st","int","ab","cls","pt"],
"query" : {"query_string":
{

"query": "((test) AND ( (test1) OR (test2))) OR (test)"}},
"facets": {
"tagid": {
"terms": {
"field": ["tagid"],"size": 100 }
}
}}

This Query is working fine..But it return value Order By rank desc..I
Don't need like that.. I need the Result Order by "Or" condition
Success...Is It Possible?

After Boosting  it's working fine... Thanks for  your idea Zachary Tong

:slight_smile:

--
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.
For more options, visit https://groups.google.com/groups/opt_out.