All, We had a requirement in our solr powered application where customers want to see all the documents that have a blank value for a field. So when they facet on a field, if the field has null values, they should be able select that facet value and see all documents. I thought facet.missing=true was the answer.
When I set facet.missing=true in solrconfig.xml, I expected to get facet values that are null along with their count. However, when there is no null value, I do not want the null to be returned along with a count of zero, which is what is happening now. Background information: Using SolrJ with Solr 3.4 and jdk7 Sample program SolrQuery facquery= new SolrQuery(); facquery.setQuery("*:*"); facquery.addFilterQuery("Field2:\"ISC\""); facquery.setRows(0); facquery.setFacet(true); facquery.setFacetMinCount(1); facquery.setFacetLimit(2); String[] orderedFacetList = new String[] {"Field1", "Field2", "Field3"}; for(int i=0; i < orderedFacetList.length; i++) { facquery.addFacetField(orderedFacetList[i]); } try { facResponse = server.query(facquery); }catch(SolrServerException ex) { } FacetField ff1=facResponse.getFacetField("Field2"); int count = ff1.getValueCount();//This gives count of 2 List<FacetField.Count> flist = ff1.getValues(); //The values are [ISC (1077), null (0)] In the above program, I am applying a filter on the field Field2 with a value ISC. So the results will be only documents that have ISC for Field2. My expectation is that flist in above program should only return [ISC (1077)]. Appreciate any pointers on this. Thank you - Rahul