How to score results based on value of a different field

Hello,
I'm running esearch 0.90 and are running queries where I would like the
output ranked and sorted by another field.

A couple examples

I have data such as

id, name, address, group
1,john,Laurel, 1
2,mike, Southold,1
3,pete,north,5
4,pete,smithtown,3
5,jackson,laurelton,2

What I would like to do is query by a field such as Name but be able to use
the "group" field as part of the ranking.

So if I query where name = 'pete' I want the group with the lowest
numbers to have a higher score.

So
4,pete,smithtown,3
would rank higher then
3,pete,north,5

I also might want to do a bounding box query and then rank all the results
by group.

When I add the sort by group it "nulls" the score for all my records.

--
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.

1 Like

Hi Dave,

If you add _score as a secondary sort it will come back:

"sort": [
{
"group": {
"order": "asc"
}
},
"_score"
]

Cheers,
Boaz

On Thursday, May 23, 2013 2:54:22 PM UTC+2, Dave O wrote:

Hello,
I'm running esearch 0.90 and are running queries where I would like the
output ranked and sorted by another field.

A couple examples

I have data such as

id, name, address, group
1,john,Laurel, 1
2,mike, Southold,1
3,pete,north,5
4,pete,smithtown,3
5,jackson,laurelton,2

What I would like to do is query by a field such as Name but be able to
use the "group" field as part of the ranking.

So if I query where name = 'pete' I want the group with the lowest
numbers to have a higher score.

So
4,pete,smithtown,3
would rank higher then
3,pete,north,5

I also might want to do a bounding box query and then rank all the results
by group.

When I add the sort by group it "nulls" the score for all my records.

--
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.

Great! Thank you! This works great!

On Thursday, May 23, 2013 9:22:45 AM UTC-4, Boaz Leskes wrote:

Hi Dave,

If you add _score as a secondary sort it will come back:

"sort": [
{
"group": {
"order": "asc"
}
},
"_score"
]

Cheers,
Boaz

On Thursday, May 23, 2013 2:54:22 PM UTC+2, Dave O wrote:

Hello,
I'm running esearch 0.90 and are running queries where I would like the
output ranked and sorted by another field.

A couple examples

I have data such as

id, name, address, group
1,john,Laurel, 1
2,mike, Southold,1
3,pete,north,5
4,pete,smithtown,3
5,jackson,laurelton,2

What I would like to do is query by a field such as Name but be able to
use the "group" field as part of the ranking.

So if I query where name = 'pete' I want the group with the lowest
numbers to have a higher score.

So
4,pete,smithtown,3
would rank higher then
3,pete,north,5

I also might want to do a bounding box query and then rank all the
results by group.

When I add the sort by group it "nulls" the score for all my records.

--
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.