You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gian Marco Tagliani <gm...@gmail.com> on 2019/05/24 12:16:20 UTC
My problem with T-shirts and nested documents
Hi all,
I'm facing a problem with Nested Documents.
To illustrate my problem I'll use the example with T-shirts in stock.
For every model of a T-shirt, we can have different colors and sizes, for
each combination we have the number of items in stock.
In Solr, for every model we have a document, for every combination of color
and size we have a nested child document.
model A
- color : red, size M, quantity 8
- color : blue, size L, quantity 4
- color : white, size M, quantity 1
model B
- color yellow, size S, quantity 7
- color yellow, size M, quantity 3
model C
- color red, size M, quantity 5
- color black, size L, quantity 6
I'm interested in size M only, and I want to know our stock ordered by
quantity.
model A, color red, quantity 8
model C, color red, quantity 5
model B, color yellow, quantity 3
model A, color white, quantity 1
My first idea was using the Json Nested Facet (
https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
)
In that case I'm not able to sort by quantity nor discriminate between the
"color red" and "color white" lines for model A.
My second idea was to use the Analytics Component (
https://lucene.apache.org/solr/guide/analytics.html)
In this case I'm not able to get data from father and child document to
build a facet.
Has any of you encountered a similar problem? Do you have any idea on how
to address my case?
Thanks in advance
Gian Marco Tagliani
Re: My problem with T-shirts and nested documents
Posted by Walter Underwood <wu...@wunderwood.org>.
If it really is a search problem, without transactional updates, I’d flatten and denormalize.
Make a non-nested document for each kind of search response you want.
wunder
Walter Underwood
wunder@wunderwood.org
http://observer.wunderwood.org/ (my blog)
> On May 27, 2019, at 3:55 AM, Gian Marco Tagliani <gm...@gmail.com> wrote:
>
> Hi Walter,
> It was just an example, I thought it was simpler to explain than my real
> problem.
>
> thanks,
> GM
>
> On Fri, May 24, 2019 at 4:47 PM Walter Underwood <wu...@wunderwood.org>
> wrote:
>
>> If you are really keeping inventory, use a relational database. Solr is a
>> really poor choice for this kind of application.
>>
>> wunder
>> Walter Underwood
>> wunder@wunderwood.org
>> http://observer.wunderwood.org/ (my blog)
>>
>>> On May 24, 2019, at 6:12 AM, Mikhail Khludnev <mk...@apache.org> wrote:
>>>
>>> It's possible to search for stocks filtering by M, sorting by qty, and
>> then
>>> parent docs need to be added to result list.
>>> Unfortunately, there is no [parent] result transformer. Thus it can be
>> done
>>> with generic
>>>
>> https://lucene.apache.org/solr/guide/6_6/transforming-result-documents.html#TransformingResultDocuments-_subquery_
>>> .
>>>
>>>
>>> On Fri, May 24, 2019 at 3:16 PM Gian Marco Tagliani <
>> gm.tagliani@gmail.com>
>>> wrote:
>>>
>>>> Hi all,
>>>> I'm facing a problem with Nested Documents.
>>>>
>>>> To illustrate my problem I'll use the example with T-shirts in stock.
>>>> For every model of a T-shirt, we can have different colors and sizes,
>> for
>>>> each combination we have the number of items in stock.
>>>>
>>>> In Solr, for every model we have a document, for every combination of
>> color
>>>> and size we have a nested child document.
>>>>
>>>>
>>>> model A
>>>> - color : red, size M, quantity 8
>>>> - color : blue, size L, quantity 4
>>>> - color : white, size M, quantity 1
>>>>
>>>> model B
>>>> - color yellow, size S, quantity 7
>>>> - color yellow, size M, quantity 3
>>>>
>>>> model C
>>>> - color red, size M, quantity 5
>>>> - color black, size L, quantity 6
>>>>
>>>>
>>>> I'm interested in size M only, and I want to know our stock ordered by
>>>> quantity.
>>>>
>>>> model A, color red, quantity 8
>>>> model C, color red, quantity 5
>>>> model B, color yellow, quantity 3
>>>> model A, color white, quantity 1
>>>>
>>>>
>>>>
>>>> My first idea was using the Json Nested Facet (
>>>>
>>>>
>> https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
>>>> )
>>>> In that case I'm not able to sort by quantity nor discriminate between
>> the
>>>> "color red" and "color white" lines for model A.
>>>>
>>>> My second idea was to use the Analytics Component (
>>>> https://lucene.apache.org/solr/guide/analytics.html)
>>>> In this case I'm not able to get data from father and child document to
>>>> build a facet.
>>>>
>>>> Has any of you encountered a similar problem? Do you have any idea on
>> how
>>>> to address my case?
>>>>
>>>>
>>>> Thanks in advance
>>>> Gian Marco Tagliani
>>>>
>>>
>>>
>>> --
>>> Sincerely yours
>>> Mikhail Khludnev
>>
>>
Re: My problem with T-shirts and nested documents
Posted by Gian Marco Tagliani <gm...@gmail.com>.
Hi Walter,
It was just an example, I thought it was simpler to explain than my real
problem.
thanks,
GM
On Fri, May 24, 2019 at 4:47 PM Walter Underwood <wu...@wunderwood.org>
wrote:
> If you are really keeping inventory, use a relational database. Solr is a
> really poor choice for this kind of application.
>
> wunder
> Walter Underwood
> wunder@wunderwood.org
> http://observer.wunderwood.org/ (my blog)
>
> > On May 24, 2019, at 6:12 AM, Mikhail Khludnev <mk...@apache.org> wrote:
> >
> > It's possible to search for stocks filtering by M, sorting by qty, and
> then
> > parent docs need to be added to result list.
> > Unfortunately, there is no [parent] result transformer. Thus it can be
> done
> > with generic
> >
> https://lucene.apache.org/solr/guide/6_6/transforming-result-documents.html#TransformingResultDocuments-_subquery_
> > .
> >
> >
> > On Fri, May 24, 2019 at 3:16 PM Gian Marco Tagliani <
> gm.tagliani@gmail.com>
> > wrote:
> >
> >> Hi all,
> >> I'm facing a problem with Nested Documents.
> >>
> >> To illustrate my problem I'll use the example with T-shirts in stock.
> >> For every model of a T-shirt, we can have different colors and sizes,
> for
> >> each combination we have the number of items in stock.
> >>
> >> In Solr, for every model we have a document, for every combination of
> color
> >> and size we have a nested child document.
> >>
> >>
> >> model A
> >> - color : red, size M, quantity 8
> >> - color : blue, size L, quantity 4
> >> - color : white, size M, quantity 1
> >>
> >> model B
> >> - color yellow, size S, quantity 7
> >> - color yellow, size M, quantity 3
> >>
> >> model C
> >> - color red, size M, quantity 5
> >> - color black, size L, quantity 6
> >>
> >>
> >> I'm interested in size M only, and I want to know our stock ordered by
> >> quantity.
> >>
> >> model A, color red, quantity 8
> >> model C, color red, quantity 5
> >> model B, color yellow, quantity 3
> >> model A, color white, quantity 1
> >>
> >>
> >>
> >> My first idea was using the Json Nested Facet (
> >>
> >>
> https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
> >> )
> >> In that case I'm not able to sort by quantity nor discriminate between
> the
> >> "color red" and "color white" lines for model A.
> >>
> >> My second idea was to use the Analytics Component (
> >> https://lucene.apache.org/solr/guide/analytics.html)
> >> In this case I'm not able to get data from father and child document to
> >> build a facet.
> >>
> >> Has any of you encountered a similar problem? Do you have any idea on
> how
> >> to address my case?
> >>
> >>
> >> Thanks in advance
> >> Gian Marco Tagliani
> >>
> >
> >
> > --
> > Sincerely yours
> > Mikhail Khludnev
>
>
Re: My problem with T-shirts and nested documents
Posted by Walter Underwood <wu...@wunderwood.org>.
If you are really keeping inventory, use a relational database. Solr is a really poor choice for this kind of application.
wunder
Walter Underwood
wunder@wunderwood.org
http://observer.wunderwood.org/ (my blog)
> On May 24, 2019, at 6:12 AM, Mikhail Khludnev <mk...@apache.org> wrote:
>
> It's possible to search for stocks filtering by M, sorting by qty, and then
> parent docs need to be added to result list.
> Unfortunately, there is no [parent] result transformer. Thus it can be done
> with generic
> https://lucene.apache.org/solr/guide/6_6/transforming-result-documents.html#TransformingResultDocuments-_subquery_
> .
>
>
> On Fri, May 24, 2019 at 3:16 PM Gian Marco Tagliani <gm...@gmail.com>
> wrote:
>
>> Hi all,
>> I'm facing a problem with Nested Documents.
>>
>> To illustrate my problem I'll use the example with T-shirts in stock.
>> For every model of a T-shirt, we can have different colors and sizes, for
>> each combination we have the number of items in stock.
>>
>> In Solr, for every model we have a document, for every combination of color
>> and size we have a nested child document.
>>
>>
>> model A
>> - color : red, size M, quantity 8
>> - color : blue, size L, quantity 4
>> - color : white, size M, quantity 1
>>
>> model B
>> - color yellow, size S, quantity 7
>> - color yellow, size M, quantity 3
>>
>> model C
>> - color red, size M, quantity 5
>> - color black, size L, quantity 6
>>
>>
>> I'm interested in size M only, and I want to know our stock ordered by
>> quantity.
>>
>> model A, color red, quantity 8
>> model C, color red, quantity 5
>> model B, color yellow, quantity 3
>> model A, color white, quantity 1
>>
>>
>>
>> My first idea was using the Json Nested Facet (
>>
>> https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
>> )
>> In that case I'm not able to sort by quantity nor discriminate between the
>> "color red" and "color white" lines for model A.
>>
>> My second idea was to use the Analytics Component (
>> https://lucene.apache.org/solr/guide/analytics.html)
>> In this case I'm not able to get data from father and child document to
>> build a facet.
>>
>> Has any of you encountered a similar problem? Do you have any idea on how
>> to address my case?
>>
>>
>> Thanks in advance
>> Gian Marco Tagliani
>>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
Re: My problem with T-shirts and nested documents
Posted by Gian Marco Tagliani <gm...@gmail.com>.
Hi Mikhail,
thanks for the quick response!
I'll try to do it with your suggestion
Many thanks :)
On Fri, May 24, 2019 at 3:12 PM Mikhail Khludnev <mk...@apache.org> wrote:
> It's possible to search for stocks filtering by M, sorting by qty, and then
> parent docs need to be added to result list.
> Unfortunately, there is no [parent] result transformer. Thus it can be done
> with generic
>
> https://lucene.apache.org/solr/guide/6_6/transforming-result-documents.html#TransformingResultDocuments-_subquery_
> .
>
>
> On Fri, May 24, 2019 at 3:16 PM Gian Marco Tagliani <gm.tagliani@gmail.com
> >
> wrote:
>
> > Hi all,
> > I'm facing a problem with Nested Documents.
> >
> > To illustrate my problem I'll use the example with T-shirts in stock.
> > For every model of a T-shirt, we can have different colors and sizes, for
> > each combination we have the number of items in stock.
> >
> > In Solr, for every model we have a document, for every combination of
> color
> > and size we have a nested child document.
> >
> >
> > model A
> > - color : red, size M, quantity 8
> > - color : blue, size L, quantity 4
> > - color : white, size M, quantity 1
> >
> > model B
> > - color yellow, size S, quantity 7
> > - color yellow, size M, quantity 3
> >
> > model C
> > - color red, size M, quantity 5
> > - color black, size L, quantity 6
> >
> >
> > I'm interested in size M only, and I want to know our stock ordered by
> > quantity.
> >
> > model A, color red, quantity 8
> > model C, color red, quantity 5
> > model B, color yellow, quantity 3
> > model A, color white, quantity 1
> >
> >
> >
> > My first idea was using the Json Nested Facet (
> >
> >
> https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
> > )
> > In that case I'm not able to sort by quantity nor discriminate between
> the
> > "color red" and "color white" lines for model A.
> >
> > My second idea was to use the Analytics Component (
> > https://lucene.apache.org/solr/guide/analytics.html)
> > In this case I'm not able to get data from father and child document to
> > build a facet.
> >
> > Has any of you encountered a similar problem? Do you have any idea on how
> > to address my case?
> >
> >
> > Thanks in advance
> > Gian Marco Tagliani
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>
Re: My problem with T-shirts and nested documents
Posted by Mikhail Khludnev <mk...@apache.org>.
It's possible to search for stocks filtering by M, sorting by qty, and then
parent docs need to be added to result list.
Unfortunately, there is no [parent] result transformer. Thus it can be done
with generic
https://lucene.apache.org/solr/guide/6_6/transforming-result-documents.html#TransformingResultDocuments-_subquery_
.
On Fri, May 24, 2019 at 3:16 PM Gian Marco Tagliani <gm...@gmail.com>
wrote:
> Hi all,
> I'm facing a problem with Nested Documents.
>
> To illustrate my problem I'll use the example with T-shirts in stock.
> For every model of a T-shirt, we can have different colors and sizes, for
> each combination we have the number of items in stock.
>
> In Solr, for every model we have a document, for every combination of color
> and size we have a nested child document.
>
>
> model A
> - color : red, size M, quantity 8
> - color : blue, size L, quantity 4
> - color : white, size M, quantity 1
>
> model B
> - color yellow, size S, quantity 7
> - color yellow, size M, quantity 3
>
> model C
> - color red, size M, quantity 5
> - color black, size L, quantity 6
>
>
> I'm interested in size M only, and I want to know our stock ordered by
> quantity.
>
> model A, color red, quantity 8
> model C, color red, quantity 5
> model B, color yellow, quantity 3
> model A, color white, quantity 1
>
>
>
> My first idea was using the Json Nested Facet (
>
> https://lucene.apache.org/solr/guide/json-facet-api.html#nested-facet-example
> )
> In that case I'm not able to sort by quantity nor discriminate between the
> "color red" and "color white" lines for model A.
>
> My second idea was to use the Analytics Component (
> https://lucene.apache.org/solr/guide/analytics.html)
> In this case I'm not able to get data from father and child document to
> build a facet.
>
> Has any of you encountered a similar problem? Do you have any idea on how
> to address my case?
>
>
> Thanks in advance
> Gian Marco Tagliani
>
--
Sincerely yours
Mikhail Khludnev