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 Donnie McNeal <do...@gmail.com> on 2012/03/01 23:40:39 UTC

Making additional solr requests in an QueryResponseWriter

Hi all,

The documents in our solr index have an parent child relationship which we
have basically flattened in our solr queries. We have messaged solr into
being the query API for a 3rd party data.  The relationship is simple
parent-child relationship as follows:

category
+-sub-category

this ultimately maps to something like this in our Model:

class Category

List<Category> getChildCategories();

Currently, in our application code we were thinking about issuing 2 queries
one to get the parent category, and one to get the sub-categories of the
parent.  We would then assemble the results in our model.

What I was wondering is would it be feasible (or even an ok practice) to
create a QueryResponseWriter (more than likely subclass an existing one
like XMLResponseFormat) that when requested it issue an additional call to
fetch the sub categories and add them to the original category document.
 Please be gentle with me :).

Maybe we just need to create the index a little bit differently to better
handle this relationship.

Thanks,

Donnie

Re: Making additional solr requests in an QueryResponseWriter

Posted by Donnie McNeal <do...@gmail.com>.
Mikhail,

Thanks for the reply.  Regarding your comments:

1 - OK. That's good to know.

2 - I thought about adding the subcategories to the category after I sent
my original question. This could work, but there are times when we need the
subcategories returned within the parent document and times where we don't
need them.

I'll try another example to see if it helps explain our problem a little
better.

Suppose you have a category heirachy like this:
Music
  +- Record Label
    +- Artist 1
      +- Album A
      +- Album B
    +- Artist 2

There are times where we would want to query and retrieve a  record label
and its the artist (subcategory), but we don't want want any of the album
information from the artist. We also need to be able to just query on all
categories directly.

3 - We looked at the joins and you are right that is what we need, but we
won't be able to use solr 4.0 for a while.

Thanks,

Donnie
On Mar 1, 2012 10:22 PM, "Mikhail Khludnev" <mk...@griddynamics.com>
wrote:

> Hello Donnie,
>
> 1. Nothing beside of design consideration prevents you form doing search in
> QueryResponseWriter. You have a request, which isn't closed yet, where you
> can obtain searcher from.
> 2. Your usecase isn't clear. If you need just to search categories, and
> return the lists of subcategories per every category found, you can just
> put your subcats list into huge stored field.
> 3. Otherwise, it sounds like http://wiki.apache.org/solr/Join or like
> https://issues.apache.org/jira/browse/SOLR-3076 , which is in really early
> stage, though.
>
> Regards
>
> On Fri, Mar 2, 2012 at 2:40 AM, Donnie McNeal <donnie.mcneal@gmail.com
> >wrote:
>
> > Hi all,
> >
> > The documents in our solr index have an parent child relationship which
> we
> > have basically flattened in our solr queries. We have messaged solr into
> > being the query API for a 3rd party data.  The relationship is simple
> > parent-child relationship as follows:
> >
> > category
> > +-sub-category
> >
> > this ultimately maps to something like this in our Model:
> >
> > class Category
> >
> > List<Category> getChildCategories();
> >
> > Currently, in our application code we were thinking about issuing 2
> queries
> > one to get the parent category, and one to get the sub-categories of the
> > parent.  We would then assemble the results in our model.
> >
> > What I was wondering is would it be feasible (or even an ok practice) to
> > create a QueryResponseWriter (more than likely subclass an existing one
> > like XMLResponseFormat) that when requested it issue an additional call
> to
> > fetch the sub categories and add them to the original category document.
> >  Please be gentle with me :).
> >
> > Maybe we just need to create the index a little bit differently to better
> > handle this relationship.
> >
> > Thanks,
> >
> > Donnie
> >
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Lucid Certified
> Apache Lucene/Solr Developer
> Grid Dynamics
>
> <http://www.griddynamics.com>
>  <mk...@griddynamics.com>
>

Re: Making additional solr requests in an QueryResponseWriter

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello Donnie,

1. Nothing beside of design consideration prevents you form doing search in
QueryResponseWriter. You have a request, which isn't closed yet, where you
can obtain searcher from.
2. Your usecase isn't clear. If you need just to search categories, and
return the lists of subcategories per every category found, you can just
put your subcats list into huge stored field.
3. Otherwise, it sounds like http://wiki.apache.org/solr/Join or like
https://issues.apache.org/jira/browse/SOLR-3076 , which is in really early
stage, though.

Regards

On Fri, Mar 2, 2012 at 2:40 AM, Donnie McNeal <do...@gmail.com>wrote:

> Hi all,
>
> The documents in our solr index have an parent child relationship which we
> have basically flattened in our solr queries. We have messaged solr into
> being the query API for a 3rd party data.  The relationship is simple
> parent-child relationship as follows:
>
> category
> +-sub-category
>
> this ultimately maps to something like this in our Model:
>
> class Category
>
> List<Category> getChildCategories();
>
> Currently, in our application code we were thinking about issuing 2 queries
> one to get the parent category, and one to get the sub-categories of the
> parent.  We would then assemble the results in our model.
>
> What I was wondering is would it be feasible (or even an ok practice) to
> create a QueryResponseWriter (more than likely subclass an existing one
> like XMLResponseFormat) that when requested it issue an additional call to
> fetch the sub categories and add them to the original category document.
>  Please be gentle with me :).
>
> Maybe we just need to create the index a little bit differently to better
> handle this relationship.
>
> Thanks,
>
> Donnie
>



-- 
Sincerely yours
Mikhail Khludnev
Lucid Certified
Apache Lucene/Solr Developer
Grid Dynamics

<http://www.griddynamics.com>
 <mk...@griddynamics.com>