The standard way that Solr
builds the index is with an Inverted index
, this makes search very fast & efficient.Well I am clear with Inverted
& Backward
indexes, but why Inverted Index is not good when it comes for Faceting
or Sorting
the data ? I Googled it, but got no satisfactory explanation.
PS : We use DocValues field type for fields needs to be used while Faceting or Sorting (DocValue fields are now column-oriented fields with a document-to-value mapping built at index time).
Anyone has got a clear explanantion for this ? Thanks
The reason is that it's expensive to compute the count of documents actually containing the facets. For each term you're practically doing a search for that term and intersecting it with the set of documents that you've already retrieved, finding out how many documents is contained in both the previous and the new set. The inverted index doesn't provide anything (directly) useful to do this.
There is a lot of literature available on the subject, and a discussion would be too broad for what a stack overflow answer can provide. The "What is in a Lucene index?" presentation from last year's Lucene Solr Revolution also provides some insight.