Dialog with myself from solr-users mailing list:
Per Steffensen skrev:
Due to what we have seen in recent tests I got in doubt how Solr search is actually supposed to behave
- Searching with "distrib=true&q=:&rows=10&collection=x,y,z&sort=timestamp asc"
- Is Solr supposed to return the 10 documents with the lowest timestamp across all documents in all slices of collection x, y and z, or is it supposed to just pick 10 random documents from those slices and just sort those 10 randomly selected documents?
- Put in another way - is this search supposed to be consistent, returning exactly the same set of documents when performed several times (no documents are updated between consecutive searches)?
Fortunately I believe the answer is, that it ought to "return the 10 documents with the lowest timestamp across all documents in all slices of collection x, y and Z". The reason I asked was because I got different responses for consecutive simular requests. Now I believe it can be explained by the bug described below. I guess they you do cross-collection/shard searches, the "request-handling" Solr forwards the query to all involved shards simultanious and merges sub-results into the final result as they are returned from the shards. Because of the "consider documents with same id as the same document even though the come from different collections"-bug it is kinda random (depending on which shards responds first/last), for a given id, what collection the document with that specific id is taken from. And if documents with the same id from different collections has different timestamp it is random where that document ends up in the final sorted result.
So i believe this inconsistency can be explained by the bug described below.
- A search returns a "numFound"-field telling how many documents all in all matches the search-criteria, even though not all those documents are returned by the search. It is a crazy question to ask, but I will do it anyway because we actually see a problem with this. Isnt it correct that two searches which only differs on the "rows"-number (documents to be returned) should always return the same value for "numFound"?
Well I found out myself what the problem is (or seems to be) - see:
Until 4.0 this "bug" could be "ignored" because it was ok for a cross-shards search to consider documents with identical id's as dublets and therefore only returning/counting one of them. It is still, in 4.0, ok within the same collection, but across collections identical id's should not be considered dublicates and should not reduce documents returned/counted. So i believe this "feature" has now become a bug in 4.0 when it comes to cross-collections searches.