Search code examples
solrsolrcloud

How to disable caching for sort query in solr?


I am sorting by 'id' field which has 25 million unique values. Hence after sorting I could see the fieldcache populated for 'id' field with more than 1 GB. Hence I want to disable making entry in fieldcache because I can optimize for Heapmemory with performance.I tried giving q={!cache=false}*.* but could still see the fieldcache is populated with id field. I also gave docValues=true,indexed=false and stored=false but nothing could prevent 'id' field from populating in fieldcache. I am using solr 5.2.1 in cloud mode. Is there any way to achieve this?


Solution

  • After changing the field definition you'll have to reindex all the documents. Since the change to using docValues won't get populated for all the documents otherwise, you'll still end up with the old structure taking up space in your field cache.

    If you're just reindexing a single document and then committing that one, that document is the only one where docValues has been populated. Optimizing the index will merge the segments that make up the index, but not rewrite their content.

    I'm not familiar with a way to disable the field cache. Since it's a low level Lucene concept, Solr can't really do much about it.