1 to n and join condition query


(zhuoming chen) #1

I have some data that are 1 to n relationship, what should I do to store
the data and query them?
Has anyone came to this situation ?
e.g.
I have the item model,but also, per item has many order,if I want to query
both the item and order,it is difficult, I have learned about that the
parent child relationship can solve this query,but it is not perfect, it
can't sort on the child filed

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


(Alexander Reelsen) #2

Hey,

there are several solutions to this problem:

  1. Denormalize your data. This is highly dependent on your data upgrade
    patterns and can possibly result in a bad performance or complex
    application/update logic
  2. Use Parent/Child to prevent heavy updates (because you can have a
    relation between employee and employer for example, but still index those
    entries as completely different documents)
  3. Use nested documents to execute more complex queries, but still keep
    everything in one document

A couple of links (the blog post contains many links to the elasticsearch
documentations)


http://www.elasticsearch.org/videos/bbuzz2013-document-relations-with-elasticsearch/

--Alex

On Wed, Nov 6, 2013 at 5:30 AM, zhuoming chen zhuomingemail@gmail.comwrote:

I have some data that are 1 to n relationship, what should I do to store
the data and query them?
Has anyone came to this situation ?
e.g.
I have the item model,but also, per item has many order,if I want to query
both the item and order,it is difficult, I have learned about that the
parent child relationship can solve this query,but it is not perfect, it
can't sort on the child filed

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


(system) #3