tags:

views:

23

answers:

1

Hi all,
In one of my latest projects I use Solr 1.4 for searching products.However I have ran into a slight problem, which I aint sure if its possible to do using Solr.

All products are indexed by "country" and "category" and the "id", "class" and "description" are stored values. I now have been requested to extract a sample list of products that we have for a give "category" and "ONLY RETURNING ONE" product for each country where the product is available.

In my current implementation, I have a dismax query to get a list of all the countries that correspond to the catergory, then I call again solr to extract all products for each country, limiting the no. rows by the size of the countries found in the previous query.

The problem I have with this current implementation is I can not be certain that I have one product for each country in the list. Therefore would anyone know if it possible to tell solr that you want only one product per country provided in the query?

Any guidance would be useful.

A: 

Take a look at Field collapsing. It allows you to do something analogous to a GROUP BY in SQL. Unfortunately, as of this writing, this feature is not even in trunk. You have to download the latest patch from the issue tracker, apply it to trunk and compile.

Mauricio Scheffer
Thanks Mauricio, when I get a chance I will try this out.I also seen another new feature of 1.5 will be a Batch Request Handler.Thanks again
Garytxo
Hi Mauricio, I eventualy got round to testing it and this seems to work fine. Thanks again.
Garytxo