Firstly apologies as I originally sent this to the dev list by mistake...

Bit of a weird one and not sure if this counts as a bug.

I erroneously created a filter which correctly filters a term into the index 
(e.g. clouds -> cloud), however if that term is filtered again it returns no 
value (e.g. cloud -> null). This was an invisible issue until I used pivoting. 
If I used the caches then I got:

SEVERE: java.lang.NullPointerException
        at 
java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
        at 
java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:988)
        at 
org.apache.solr.util.ConcurrentLRUCache.get(ConcurrentLRUCache.java:89)
        at org.apache.solr.search.FastLRUCache.get(FastLRUCache.java:130)
        at 
org.apache.solr.search.SolrIndexSearcher.getDocSet(SolrIndexSearcher.java:1232)
        at 
org.apache.solr.handler.component.PivotFacetProcessor.getSubset(PivotFacetProcessor.java:244)

However if I turned the caches off I got a more descriptive error:

SEVERE: java.lang.IllegalArgumentException: Query and filter cannot be null.
        at org.apache.lucene.search.FilteredQuery.<init>(FilteredQuery.java:68)
        at org.apache.lucene.search.FilteredQuery.<init>(FilteredQuery.java:54)
        at 
org.apache.lucene.search.IndexSearcher.wrapFilter(IndexSearcher.java:228)
        at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:297)
        at 
org.apache.solr.search.SolrIndexSearcher.getDocSetNC(SolrIndexSearcher.java:1197)
        at 
org.apache.solr.search.SolrIndexSearcher.getDocSet(SolrIndexSearcher.java:1241)
        at 
org.apache.solr.handler.component.PivotFacetProcessor.getSubset(PivotFacetProcessor.java:244)

The issue seems to be in the PivotFacetProcessor.getSubset method in the 
following two lines

     Query query = ft.getFieldQuery(null, field, pivotValue);
     return searcher.getDocSet(query, base);

In my case ft.getFieldQuery returns a null, which causes the Exception.

As I said my filter was incorrect, however there may be some weird, but valid, 
case where the filter does change the term if it’s passed through multiple 
times (something like a decrement number or date filter). In which case the 
PivotFacetProcessor would not cause a NPE but would produce incorrect values.

So...

1) It might be nice to throw a similar Exception if the caches are used
2) I’m not sure why the pivotValue, which is taken from the index, is re-parsed 
through the filters. Surely if the value is taken from the index it would be 
more efficient (and correct) to just create a TermQuery.

N

Reply via email to