[ 
https://issues.apache.org/jira/browse/SOLR-5725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15453150#comment-15453150
 ] 

Mikhail Khludnev commented on SOLR-5725:
----------------------------------------

Here is how I caught the logic for {{facet.exists=true}}. Please have a look! 
[~romseygeek] you are also invited to look at it. 
{code}
   /**
    * @param existsRequested facet.exists=true is passed for the given field
    * */
  static FacetMethod selectFacetMethod(String fieldName, 
                                       SchemaField field, FacetMethod method, 
Integer mincount,
                                       boolean existsRequested) {
    if (existsRequested) {
      //checkMincountOnEnumprobing(fieldName, mincount);
      if (mincount > 1) {
        throw new SolrException (ErrorCode.BAD_REQUEST,
            FacetParams.FACET_MINCOUNT + "=" + mincount + " exceed 1 that's not 
supported with " + 
                FacetParams.FACET_EXISTS + "=true for " + fieldName
        );
      }
      // suggesting default if absent
      if (method == null) {
        method = FacetMethod.ENUM;
      }
    }
    final FacetMethod facetMethod = selectFacetMethod(field, method, mincount);
    
    if (existsRequested && facetMethod != FacetMethod.ENUM) {
      throw new SolrException (ErrorCode.BAD_REQUEST, 
          FacetParams.FACET_EXISTS + "=true is requested, but " +
          FacetParams.FACET_METHOD + "=" + FacetParams.FACET_METHOD_enum + " 
can't be used with " + fieldName
      );
    }
    return facetMethod;
  }
{code}
I'm waiting for confirmation before shaking up the tests.  


> Efficient facets without counts for enum method
> -----------------------------------------------
>
>                 Key: SOLR-5725
>                 URL: https://issues.apache.org/jira/browse/SOLR-5725
>             Project: Solr
>          Issue Type: Improvement
>          Components: search
>            Reporter: Alexey Kozhemiakin
>            Assignee: Mikhail Khludnev
>             Fix For: master (7.0), 6.3
>
>         Attachments: SOLR-5725-5x.patch, SOLR-5725-master.patch, 
> SOLR-5725.patch, SOLR-5725.patch, SOLR-5725.patch, SOLR-5725.patch, 
> SOLR-5725.patch
>
>
> Shot version:
> This improves performance for facet.method=enum when it's enough to know that 
> facet count>0, for example when you it's when you dynamically populate 
> filters on search form. New method checks if two bitsets intersect instead of 
> counting intersection size.
> Long version:
> We have a dataset containing hundreds of millions of records, we facet by 
> dozens of fields with many of facet-excludes and have relatively small number 
> of unique values in fields, around thousands.
> Before executing search, users work with "advanced search" form, our  goal is 
> to populate dozens of filters with values which are applicable with other 
> selected values, so basically this is a use case for facets with mincount=1, 
> but without need in actual counts.
> Our performance tests showed that facet.method=enum works much better than 
> fc\fcs, probably due to a specific ratio of "docset"\"unique terms count". 
> For example average execution of query time with method fc=1500ms, fcs=2600ms 
> and with enum=280ms. Profiling indicated the majority time for enum was spent 
> on intersecting docsets.
> Hers's a patch that introduces an extension to facet calculation for 
> method=enum. Basically it uses docSetA.intersects(docSetB) instead of 
> docSetA. intersectionSize (docSetB).
> As a result we were able to reduce our average query time from 280ms to 60ms.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to