Quick Tip: Find Missing Fields in Apache Solr
I had an issue raised because of a mismatch between my document results and my facet counts. The issue is basically that there is a field that is not required and in most cases, the field is added with an empty string – which is ok as empty has a meaning. However in a few cases, the field is not added at all and this is not the expected scenario. So I needed to find out why did this happen, which means finding the document id so that it can be reviewed during indexing.
Oh well..I was tired so I ran a *:* query and got all results… too much text.
Query for all: q=*:*
Added only the two fields that I needed in the fl field so that only those fields that I needed were shown and number of rows to see them all. This was kind of slow and inconvenient.
Query for all with only required fields and all rows: q=*:*&fl=title myfacet&rows=1600
So now I remembered query for missing fields! Just use the – operator on a field name.
Query for documents with missing fields: q=-myfacet:*
Problem solved. Easy as pie!