Need help with Nested docs situation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help with Nested docs situation

roySolr
Hello,

I have a situation and i'm a little bit stuck on the way how to fix it.
For example the following data structure:

Deal
All Coca Cola 20% off

Products
Coca Cola light
Coca Cola Zero 1L
Coca Cola Zero 20CL
Coca Cola 1L

When somebody search to "Cola" discount i want the result of the deal with related products.

Solution #1:
I could index it with nested docs(solr 4.9). But the problem is when a product has some changes(let's say "Zero" gets a new name "Extra Light") i have to re-index every deal with these products.

Solution #2:
I could make 2 collections, one with deals and one with products. A Product will get a parentid(dealid). Then i have to do 2 queries to get the information? When i have a resultpage with 10 deals i want to preview the first 2 products. That means a lot of queries but it's doesn't have the update problem from solution #1.

Does anyone have a good solution for this?

Thanks, any help is appreciated.
Roy

Reply | Threaded
Open this post in threaded view
|

Re: Need help with Nested docs situation

Mikhail Khludnev
data scale and request rate can judge between block, plain joins and field
collapsing.

On Thu, Apr 30, 2015 at 1:07 PM, roySolr <[hidden email]> wrote:

> Hello,
>
> I have a situation and i'm a little bit stuck on the way how to fix it.
> For example the following data structure:
>
> *Deal*
> All Coca Cola 20% off
>
> *Products*
> Coca Cola light
> Coca Cola Zero 1L
> Coca Cola Zero 20CL
> Coca Cola 1L
>
> When somebody search to "Cola" discount i want the result of the deal with
> related products.
>
> Solution #1:
> I could index it with nested docs(solr 4.9). But the problem is when a
> product has some changes(let's say "Zero" gets a new name "Extra Light") i
> have to re-index every deal with these products.
>
> Solution #2:
> I could make 2 collections, one with deals and one with products. A Product
> will get a parentid(dealid). Then i have to do 2 queries to get the
> information? When i have a resultpage with 10 deals i want to preview the
> first 2 products. That means a lot of queries but it's doesn't have the
> update problem from solution #1.
>
> Does anyone have a good solution for this?
>
> Thanks, any help is appreciated.
> Roy
>
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Need-help-with-Nested-docs-situation-tp4203190.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



--
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Need help with Nested docs situation

Alessandro Benedetti-4
This scenario is a perfect fit to play with Solr Joins [1] .

As you observed, you would prefer to go with a query time join.
THis kind of join can be done inter-collection .
You can have you <deal> collection  and <product> collection .
Every product will have one field <dealId> to match all the parent deals.
When you add,remove,update a new deal, you have to update in the product
index all the related products.

Then you can query over the products and get related parent deals in the
response.
Can you give me a little bit more details about your expected use case ?
Example of queries and a better explanation of the product previews ?

Cheers

[1] https://www.youtube.com/watch?v=-OiIlIijWH0&feature=youtu.be ,
http://blog.griddynamics.com/2013/09/solr-block-join-support.html

2015-05-20 18:56 GMT+01:00 Mikhail Khludnev <[hidden email]>:

> data scale and request rate can judge between block, plain joins and field
> collapsing.
>
> On Thu, Apr 30, 2015 at 1:07 PM, roySolr <[hidden email]> wrote:
>
> > Hello,
> >
> > I have a situation and i'm a little bit stuck on the way how to fix it.
> > For example the following data structure:
> >
> > *Deal*
> > All Coca Cola 20% off
> >
> > *Products*
> > Coca Cola light
> > Coca Cola Zero 1L
> > Coca Cola Zero 20CL
> > Coca Cola 1L
> >
> > When somebody search to "Cola" discount i want the result of the deal
> with
> > related products.
> >
> > Solution #1:
> > I could index it with nested docs(solr 4.9). But the problem is when a
> > product has some changes(let's say "Zero" gets a new name "Extra Light")
> i
> > have to re-index every deal with these products.
> >
> > Solution #2:
> > I could make 2 collections, one with deals and one with products. A
> Product
> > will get a parentid(dealid). Then i have to do 2 queries to get the
> > information? When i have a resultpage with 10 deals i want to preview the
> > first 2 products. That means a lot of queries but it's doesn't have the
> > update problem from solution #1.
> >
> > Does anyone have a good solution for this?
> >
> > Thanks, any help is appreciated.
> > Roy
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://lucene.472066.n3.nabble.com/Need-help-with-Nested-docs-situation-tp4203190.html
> > Sent from the Solr - User mailing list archive at Nabble.com.
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <[hidden email]>
>



--
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England