Search code examples
solrshardingsolrcloud

SolrCloud: Is it possible to get the shard id of a document in the search results


When debugging Solr schema and indexing in a SolrCloud, it is important to easily know into which shard a document was indexed. Is it possible to define a schema field for the shard id such that the automatically assigned shard id is then available in search results?


Solution

  • You dont need to store shard id in your schema explicitly to get it in results. if in fl parameter you add [shard] with other required fields, it will return you the shard id of that document:

    /solr/collection_name/select?q=*:*&fl=[shard],*&wt=json&indent=true