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 Indika Tantrigoda <in...@gmail.com> on 2012/11/08 04:08:39 UTC

Retrieve unique documents on a non id field

Hi All,

Currently I am using Solr for searching and filtering restaurants based on
certain criteria. For example I use Solr to obtain the list of restaurants
open in the day.

A restaurant can have sessions when its open, e.g. Breakfast, Lunch and
Dinner, and the time information related to these sessions are stored in
three different documents with a field to identify the restaurant
(restaurant_id).

When I query for restaurants that are open at 11:00 AM using (start_time:[*
TO 1100] AND end_time:[1100 TO *]) and if sessions overlap (say Breakfast
and Lunch) I would get both the Breakfast document and the Lunch document.
These are in fact two different documents and would have the same
restaurant_id.

My question is, is there a way to retrive only one document if the
restaurant_id repeated in the response.

Thanks,
Indika

Re: Retrieve unique documents on a non id field

Posted by Indika Tantrigoda <in...@gmail.com>.
Hi,

Thanks for the reply. Yes, I grouped the documents based on the
restaurant_id and got 1 result per group. Setting the group.format to
simple helped with the formatting.

Thanks,
Indika

On 8 November 2012 12:10, Rafał Kuć <r....@solr.pl> wrote:

> Hello!
>
> Look at the field collapsing functionality -
> http://wiki.apache.org/solr/FieldCollapsing
>
> It allows you to group documents based on field value, query or
> function query.
>
> --
> Regards,
>  Rafał Kuć
>  Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
>
> > Hi All,
>
> > Currently I am using Solr for searching and filtering restaurants based
> on
> > certain criteria. For example I use Solr to obtain the list of
> restaurants
> > open in the day.
>
> > A restaurant can have sessions when its open, e.g. Breakfast, Lunch and
> > Dinner, and the time information related to these sessions are stored in
> > three different documents with a field to identify the restaurant
> > (restaurant_id).
>
> > When I query for restaurants that are open at 11:00 AM using
> (start_time:[*
> > TO 1100] AND end_time:[1100 TO *]) and if sessions overlap (say Breakfast
> > and Lunch) I would get both the Breakfast document and the Lunch
> document.
> > These are in fact two different documents and would have the same
> > restaurant_id.
>
> > My question is, is there a way to retrive only one document if the
> > restaurant_id repeated in the response.
>
> > Thanks,
> > Indika
>
>

Re: Retrieve unique documents on a non id field

Posted by Rafał Kuć <r....@solr.pl>.
Hello!

Look at the field collapsing functionality - http://wiki.apache.org/solr/FieldCollapsing

It allows you to group documents based on field value, query or
function query.

-- 
Regards,
 Rafał Kuć
 Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch

> Hi All,

> Currently I am using Solr for searching and filtering restaurants based on
> certain criteria. For example I use Solr to obtain the list of restaurants
> open in the day.

> A restaurant can have sessions when its open, e.g. Breakfast, Lunch and
> Dinner, and the time information related to these sessions are stored in
> three different documents with a field to identify the restaurant
> (restaurant_id).

> When I query for restaurants that are open at 11:00 AM using (start_time:[*
> TO 1100] AND end_time:[1100 TO *]) and if sessions overlap (say Breakfast
> and Lunch) I would get both the Breakfast document and the Lunch document.
> These are in fact two different documents and would have the same
> restaurant_id.

> My question is, is there a way to retrive only one document if the
> restaurant_id repeated in the response.

> Thanks,
> Indika