Hi, I wanted to know how sorting works with multiple shards.
Suppose I have queried with 4 shards specified. Records per page specified as 100 & sort-field as creationDate. So will it sort & fetch 100 documents from each shard, and then they will be aggregated, sorted again & top 100 will be given as a result discarding remaining 300? My use case is - I want to fetch documents with doc-id say A (or B or C etc.) and category W X Y Z. Solr shards are created based on field "category", so all the documents with category W are in shard-W, all the documents with type X are in shard-X and so on... 1st approach - query will be (doc-id:A AND category:(W OR X)) OR (doc-id:B AND category:(W OR Y)) OR (doc-id:C AND category:(W OR X OR Y OR Z)).... sorted on creationDate Hit the query on all the shards. 2nd approach - there will be multiple queries category:W AND (doc-id:(A OR B OR C))... sorted on creationDate. Hit this query on shard-W category:X AND (doc-id:(A OR C))... sorted on creationDate. Hit this query on shard-X category:Y AND (doc-id:(B OR C))... sorted on creationDate. Hit this query on shard-Y category:Z AND (doc-id:(C))... sorted on creationDate. Hit this query on shard-Z So there will be 4 queries, but avoiding the sort on aggregation. I am using solr 3.4 Which approach will be efficient? My assumption about the working of sorting in solr shards, is it correct? Thanks, Amey