What you want is something called 'field collapsing'. This is a Solr implementation that (at a high level) gives you one of these documents and a report of how many more match the query. Collapsing multiple product styles/colors/sizes to one consumer-visible product is a common use case for this. Another use case is the 'More results from this site' that you get from a Google search. This feature is slowly being added into the trunk.
Many people opt to fetch a few hundred records and do the "collapse" themselves in the app. There are ways to optimize pulling those records. On Wed, Aug 25, 2010 at 10:50 AM, Willie Whitehead <bwilst...@gmail.com> wrote: > Hi, > > I'm having a problem where a Solr query on all items in one category > is returning duplicated items when an item appears in more than one > subcategory. My schema involves a document for each item's subcategory > instance. I know this is not correct. > > I'm not sure if I ever tried multiple values on subcategories. (Before > the latest changes to the schema, I was only getting the first > subcategory instance and I had a problem with parentcgyid.) Could you > review the 3 results from 1 item below and advise how I can return > only Distinct values for the itmid field? > > I think it's best that I change the schema to support multiple values. > I'm currently already using faceting for the subcategories. Do I have > to use it for this purpose also, or should I move forward to improve > my schema configuration? > > <doc> > <str name="cgyid">14440</str> > <str name="itmdsc">Girl Costume</str> > <str name="itmid">GIRLCOSTUME</str> > <str name="itmkey">14440-GIRLCOSTUME</str> > <str name="itmnam">Girl Costume Girl Child</str> > <float name="lstprc">9.99</float> > <str name="parcgyid">1400</str> > <str name="parcgynam">Girls Costumes</str> > <float name="prc">8.99</float> > <str name="seoitm">girl-costume-for-child-GIRLCOSTUME</str> > <str name="seoparcgy">girls+costumes</str> > <str name="seosubcgy">occupational</str> > - > <arr name="size"> > <str>L</str> > <str>M</str> > <str>S</str> > </arr> > <str name="stock">In Stock</str> > <str name="subcgynam">Occupational|14440</str> > </doc> > - > <doc> > <str name="cgyid">14150</str> > <str name="itmdsc">Girl Costume</str> > <str name="itmid">GIRLCOSTUME</str> > <str name="itmkey">14150-GIRLCOSTUME</str> > <str name="itmnam">Girl Costume Girl Child</str> > <float name="lstprc">9.99</float> > <str name="parcgyid">1400</str> > <str name="parcgynam">Girls Costumes</str> > <float name="prc">8.99</float> > <str name="seoitm">girl-costume-for-child-GIRLCOSTUME</str> > <str name="seoparcgy">girls+costumes</str> > <str name="seosubcgy">classic</str> > - > <arr name="size"> > <str>L</str> > <str>M</str> > <str>S</str> > </arr> > <str name="stock">In Stock</str> > <str name="subcgynam">Classic|14150</str> > </doc> > - > <doc> > <str name="cgyid">14010</str> > <str name="itmdsc">Girl Costume</str> > <str name="itmid">GIRLCOSTUME</str> > <str name="itmkey">14010-GIRLCOSTUME</str> > <str name="itmnam">Girl Costume Girl Child</str> > <float name="lstprc">9.99</float> > <str name="parcgyid">1400</str> > <str name="parcgynam">Girls Costumes</str> > <float name="prc">8.99</float> > <str name="seoitm">girl-costume-for-child-GIRLCOSTUME</str> > <str name="seoparcgy">girls+costumes</str> > <str name="seosubcgy">50s+costumes</str> > - > <arr name="size"> > <str>L</str> > <str>M</str> > <str>S</str> > </arr> > <str name="stock">In Stock</str> > <str name="subcgynam">50's Costumes|14010</str> > </doc> > > > Thanks! > -- Lance Norskog goks...@gmail.com