3

I am trying to load a solr core (35MB for testing) in memory for faster request serving. For loading whole core in memory, I got to know of using RAMDirectoryFactory in my core's solrconfig.xml file. I replaced the default DirectoryFactory i.e.

<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>

with

<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>

and changed locktype to single as

<lockType>${solr.lock.type:single}</lockType>

in my core's solrconfig.xml file and then restarted the solr as bin/solr restart. But after restarting the solr, SolrAdmin interface is showing zero documents as shown in following image zero segment size. When I checked logs, I got following warnings:

enter image description here I've googled a lot to fix this problem but found nothing. I am not getting what I am missing and how to make it work.

Deadlock
  • 1,575
  • 1
  • 19
  • 34
Snjv94
  • 372
  • 1
  • 8
  • Such a small index will likely be kept in RAM anyway by your operating system. But what do you expect? If you're using a index directory backed by RAM, there won't be anything there when you start Solr. Have you tried adding documents and committing? – MatsLindh Feb 08 '18 at 12:59
  • I was testing it on small index for now. I tried to reindex the data with enabled RAMDirectoryFactory in config file. Although, Data got indexed and was visible on the interface. But again when I restart the solr, data got lost and the interface was showing zero documents. – Snjv94 Feb 09 '18 at 09:28
  • Yes, that's what a RAM Directory is. It will _not_ keep the index around after you end the Solr process. Its content only lives in RAM inside the process, and is not kept between restarts of the process. It is volatile storage and not permanent in any way. – MatsLindh Feb 09 '18 at 11:59
  • So, is there any way to keep the already indexed data (indexed using default DirectoryFactory) into the RAMDirectory without losing it and without any need of reindexing?. I mean what if I want to keep my production data over the RAM Directory for faster serving and at the same time I want to keep the index safe in case if the solr gets restarted due to some system failure and after the failure, I don't want to rebuild the whole index again? – Snjv94 Feb 10 '18 at 20:16
  • Let your OS handle it for you. It'll keep active file system blocks cached in memory, and will probably do a better job than trying to out-smart it. You can also use the explicit cache mechanisms in Solr to short circuit often seen queries and documents being read. For such a small index you can also create an explicit ramdisk on OS level and copy the index there before starting Solr, but it will still not be persisted across reboots. – MatsLindh Feb 10 '18 at 20:54

0 Answers0