Score of matched (nested) documents?


(Zachary Tong) #1

I believe the answer is "no", but wanted to check:

Is there a way to return the individual score of the nested documents that
match a query? I'm performing a query on nested docs which returns
appropriate parents, but I would like to know which nested child scored the
highest for the query. The nested score_mode simply tells me that "one of
the children scored well", but not which one. Is there any way to sort or
find the score of the nested children?

Barring that, I'm not certain of the best way to structure my data. Should
I arrange the data in two types and denormalize so that one type has a
"foreign key" (to use relational db terminology) that points at the other
type, which would then require several more queries to access the
individual documents?

Thanks!
-Zach


(Zachary Tong) #2

Looks like I found my answer here:

https://groups.google.com/d/topic/elasticsearch/1_1zXSeRsxQ/discussion

Guess I'll start down the denormalization path. IF anyone has some
comments or opinions on the best way to structure relationships in ES, I'd
love to hear. Is the general sentiment to not model relationships and
simply retrieve IDs which you use through another, non-ES mechanism to find
(say, query a database) ?

Related, what's the performance of simply looking up a specific document by
it's ID? Is it O(n)? Does ES use something like b-trees for document ID
lookups?

Thanks!
-Zach

On Sunday, August 5, 2012 7:52:54 PM UTC-4, Zachary Tong wrote:

I believe the answer is "no", but wanted to check:

Is there a way to return the individual score of the nested documents that
match a query? I'm performing a query on nested docs which returns
appropriate parents, but I would like to know which nested child scored the
highest for the query. The nested score_mode simply tells me that "one of
the children scored well", but not which one. Is there any way to sort or
find the score of the nested children?

Barring that, I'm not certain of the best way to structure my data.
Should I arrange the data in two types and denormalize so that one type
has a "foreign key" (to use relational db terminology) that points at the
other type, which would then require several more queries to access the
individual documents?

Thanks!
-Zach


(Shay Banon) #3

There is no option to get score of specific nested doc, though it has been requested to be able to return "only" the nested doc that matched the query, in which case we can possibly return the score with it. This is a very "up in the air" feature currently, not slated (or even designed) yet.

Regarding the "get" API pert, its not a btree, it will probably be a bit faster then a btree. Thats because there is a bloom filter associated with each segment, so getting a doc will almost all times find the relevant segment, and then within that segment (a segment is part of an index) its more similar to an interval based skip list.

On Aug 6, 2012, at 3:04 PM, Zachary Tong zacharyjtong@gmail.com wrote:

Looks like I found my answer here:

https://groups.google.com/d/topic/elasticsearch/1_1zXSeRsxQ/discussion

Guess I'll start down the denormalization path. IF anyone has some comments or opinions on the best way to structure relationships in ES, I'd love to hear. Is the general sentiment to not model relationships and simply retrieve IDs which you use through another, non-ES mechanism to find (say, query a database) ?

Related, what's the performance of simply looking up a specific document by it's ID? Is it O(n)? Does ES use something like b-trees for document ID lookups?

Thanks!
-Zach

On Sunday, August 5, 2012 7:52:54 PM UTC-4, Zachary Tong wrote:
I believe the answer is "no", but wanted to check:

Is there a way to return the individual score of the nested documents that match a query? I'm performing a query on nested docs which returns appropriate parents, but I would like to know which nested child scored the highest for the query. The nested score_mode simply tells me that "one of the children scored well", but not which one. Is there any way to sort or find the score of the nested children?

Barring that, I'm not certain of the best way to structure my data. Should I arrange the data in two types and denormalize so that one type has a "foreign key" (to use relational db terminology) that points at the other type, which would then require several more queries to access the individual documents?

Thanks!
-Zach


(Zachary Tong) #4

Good to know, thanks for the detailed response Shay!

-Zach

On Tuesday, August 7, 2012 5:40:09 PM UTC-4, kimchy wrote:

There is no option to get score of specific nested doc, though it has been
requested to be able to return "only" the nested doc that matched the
query, in which case we can possibly return the score with it. This is a
very "up in the air" feature currently, not slated (or even designed) yet.

Regarding the "get" API pert, its not a btree, it will probably be a bit
faster then a btree. Thats because there is a bloom filter associated with
each segment, so getting a doc will almost all times find the relevant
segment, and then within that segment (a segment is part of an index) its
more similar to an interval based skip list.

On Aug 6, 2012, at 3:04 PM, Zachary Tong <zachar...@gmail.com<javascript:>>
wrote:

Looks like I found my answer here:

https://groups.google.com/d/topic/elasticsearch/1_1zXSeRsxQ/discussion

Guess I'll start down the denormalization path. IF anyone has some
comments or opinions on the best way to structure relationships in ES, I'd
love to hear. Is the general sentiment to not model relationships and
simply retrieve IDs which you use through another, non-ES mechanism to find
(say, query a database) ?

Related, what's the performance of simply looking up a specific document
by it's ID? Is it O(n)? Does ES use something like b-trees for document
ID lookups?

Thanks!
-Zach

On Sunday, August 5, 2012 7:52:54 PM UTC-4, Zachary Tong wrote:

I believe the answer is "no", but wanted to check:

Is there a way to return the individual score of the nested documents
that match a query? I'm performing a query on nested docs which returns
appropriate parents, but I would like to know which nested child scored the
highest for the query. The nested score_mode simply tells me that "one of
the children scored well", but not which one. Is there any way to sort or
find the score of the nested children?

Barring that, I'm not certain of the best way to structure my data.
Should I arrange the data in two types and denormalize so that one type
has a "foreign key" (to use relational db terminology) that points at the
other type, which would then require several more queries to access the
individual documents?

Thanks!
-Zach


(btiernay) #5

It's been a little time since this post was created I'm curious to know if
there are any plans to add this feature (child filtering w/ score) any time
in the future?

Thanks!

--


(btiernay) #6

I suppose this is the following ticket?

On Friday, 18 January 2013 09:54:55 UTC-5, btiernay wrote:

It's been a little time since this post was created I'm curious to know if
there are any plans to add this feature (child filtering w/ score) any time
in the future?

Thanks!

--


(Nova) #7

Example: we search an address "Dien Bien Phu", but we get ["Dien Bien Phu", "Hung Vuong", Thanh Khe"], Can we rank score for every nested document in this case?
I think if so, "Dien Bien Phu" in nested document will have highest score.

How do you think about this ?


(system) #8