0
votes

I have a Solr query returning results from a collection of about 700,000 documents. It runs on a single master with one slave instance.

I filter my documents and run faceting on one field (sports_is). However, the count of the single faceting results, their combination as a facet query and applying them as a fq is different. How is that possible?

This is my fq (pretty straight forward):

fq":["type_id_v:configurable",
    "is_salable_i:1",
    "category_id_is:10143"]

This facet query

"facet.query":"sports_is:(117532 OR 117519 OR 117520 OR 117521 OR 117522 OR 117518)"

returns 177 results. When I add the facet query as fq to my query, I also get 177 results. So this seems to be the right count.

But

"facet.field":"sports_is"

returns more results if you sum the single results (the sum is 300):

    "facet_fields":{
  "sports_is":[
    "117523",2724,
    "117515",1767,
    "117514",1522,
    "117510",1423,
    "118851",502,
    "117517",473,
    "117516",458,
    "117527",327,
    "117511",297,
    "118863",240,
    "118855",181,
    "118866",175,
    "118865",160,
         "117520",149,
    "118867",97,
    "117509",88,
         "117521",58,
         "117518",42,
    "118854",42,
    "117512",38,
    "117524",38,
    "117513",37,
         "117519",36,
    "118853",17,
    "118856",17,
         "117522",15,
    "118864",9,
    "118868",7,
    "118860",2,
    "118857",1,
    "118862",1,
    "119190",1]}

How's that possible? Is the logic different between summing the single counts and getting the accumulated result?

1
how do you count 300? can you detail that process?Maurizio In denmark
also what is the field type of sport_is ?Maurizio In denmark
300 is the sum of the sport_is values 117518 to 117522 (these are queried in the facet query as well). I intended these in the facet result above. The datatype is "is", list of integer values.Juergen

1 Answers

0
votes

if you datatype is this:

<dynamicField name="*_is" type="int"    indexed="true"  stored="true"  multiValued="true"/>

that means that a single document can contain more than one id. when you apply a filter query you count the number of documents (177 in your case) but when you facet on a multivalue field you get the count of the tokens in the field, meaning you still have 177 fields but some of them probably contain more than one id for a total of 300.

Check this forum post for a similar problem: http://lucene.472066.n3.nabble.com/How-to-facet-data-from-a-multivalued-field-td3897853.html