Finding or configuring Solr home directory - solr

I'm following this tutorial on setting up django-haystack and solr: http://django-haystack.readthedocs.org/en/latest/tutorial.html
I hit a stumbling block here:
If you’re using the Solr backend, you have an extra step. Solr’s
configuration is XML-based, so you’ll need to manually regenerate the
schema. You should run ./manage.py build_solr_schema first, drop the
XML output in your Solr’s schema.xml file and restart your Solr
server.
Where is my schema.xml file located? It says it should in the Solr home directory and the .conf folder. But where is the Solr home directory, and/or how do I configure its location?

The solr home is the place where you can find your schema.xml and solrconfig.xml, as well as some other files depending on the text analysis you're using (dictionaries for stemming, stopwords etc.), and where your index gets created by default.
There are a couple of ways to configure the solr home, since it is located outside of the servlet container:
solr.solr.home java system property (most used one)
java:comp/env/solr/home for JNDI lookup
You can either check your servlet container configuration or go to the Solr admin page http://host:port/solr/admin, which prints out the actual solr home location together with other information about the solr instance running.

First check whether your Solr instance is working.
Got to -> http://localhost:8983/solr
If you can see a Solr web panel you have a live Solr instance.
Now go to Java Properties
Here you will see the the variables. This is where you can find the home DIRs
Note schema is now managed. If you want to override this you will have to hack it a bit. check here

Related

How to fix or remove Solr configuration?

I'm trying to set up Solr on RHEL as a better search engine for Drupal and admittedly I don't really know what I'm doing. I've installed Solr and am now trying to create a core. While crafting the URL, I accidently clicked on it and now I have a unusable configuration. I'm getting this error:
ylncore-name: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core ylncore-name: Error loading solr config from /var/solr/data/path/to/dir/conf/solrconfig.xml
I deleted the core via the dashboard and from the command line which didn't help. I've grepped across the drive for files with the path but can't find any. Web searching makes it sound like I have to do something with Zookeeper but I don't know what. How do I fix or delete the config so that I can start over?

How to make config changes take effect in Solr 7.3

We are using solr.SynonymFilterFactory with synonyms.txt in Solr during querying. I realized that there is an error in synonyms.txt, corrected it and uploaded the new file. I can see the modified synonyms.txt from Admin. But it looks like the queries are still using the old synonyms.txt. I am executing test queries from Admin with debugQuery=true and can see the synonyms getting used. How can this be fixed? It is a production environment with 3 nodes using zookeeper for management.
You'll need to reload your core for the changes to take effect.
In a single-node Solr you can do that from the Admin page: go to Core Admin, select your core, and hit Reload. This will slow down some queries but it shouldn't drop queries or connections.
You can also reload the core via the API:
curl 'http://localhost:8983/solr/admin/cores?action=RELOAD&core=your-core'
I am not sure how this works on an environment with 3 nodes, though.

Solr cloud - reloading elevate.xml

I am using Apache Solr 6.5 with Query Elevation Component (/elevate endpoint) to support elevation of particular documents in my queries.
I am using elevate.xml file in
<instanceDir>/conf/<config-file>
directory. However on production server (Solr configured as cloud with zookepper to maintain configuration) changes in the elevate.xml are not loaded. To check if it works, I just query the elevated phrase and as a result I get elevated documents from previous version of elevate.xml.
Of course I am restarting all Solr cloud instances after loading new version of elevate.xml and updated file is visible in the Solr's Admin UI files section (of the particular core of course).
The query I am using to test results, to prove that I am not using stardard /query component:
/elevate?df=name&fl=id,name,[elevated]&indent=on&q=heart&wt=json
What should I do to actually tell Solr that the new elevate.xml was loaded? That works fine on my development standalone configuration of Solr (not cloud one) after the solr service is restarted, the documents are elevated by updated elevate.xml file.
You should be doing this:
upload the elevate.xml file to zookeeper as explained here
reload the collection with the RELOAD collection api, no need to restart Solr
Ok I think I figured it out. The problem was with a directory in which elevate.xml file was anticipated by Solr.
The documentation states (as for 6.5.0 version)
config-file
Path to the file that defines query elevation.
This file must exist in <instanceDir>/conf/<config-file> or <dataDir>/<config-file>.
In my dev configuration that was true for both cases (the file was read either from conf or data directory). However on production (in cloud environment with external zooKeepers) the file was read from the root directory of a core (aka collection), where also solrconfig.xml and schema.xml exists.
Probably it has some explanation and it's just data dir itself, but since I don't know how to check what are values of instanceDir and dataDir variables, the documentation was misleading for me.
I hope it helps other Solr adepts.

how to backup solrconfig file from running solr

I have a single core solr server. when solr was running, in one collection solrconfig.xml and schema.xml files replaced by mistake.
now collection worked correctly and correctly response to request but valid file in conf folder is replaced by mistake files. surly if i reload collection, new bad files load and my collection not worked correctly.
is there a way than can get solrconfig.xml & schema.xml from running collection without considering solrconfig.xml and schema.xml files that exist in conf folder?
You can read the current running schema and config through the Solr schema API and Solr config API.
Pay attention: the results of this APIs is not the original schema.xml or solrconfig.xml files but from that you can rebuild the originals.
Again, pay also attention that Solr config API is available only in recent version of Solr.
In older versions (I have tested version 4.8.1) are no API for the solr configuration, so there is no way to fully rebuild the solrconfig.xml file.
You can retrieve the loaded configuration files using Solr Administration User Interface :
Go to http://<hostname>:<port>/solr.
Select your core in the dropdown menu in the left pane.
A menu apears below the selected core, select Files
Load the file you want
Or you can go straight to http://<hostname>/solr/#/<corename>/files?file=<filename>
See https://cwiki.apache.org/confluence/display/solr/Files+Screen
Solr version prior to 4.x shows a slightly different interface, if I remember correctly there is no core dropdown, solrconfig.xml & schema.xml appears right in the left pane.
On SolrCloud there is an additional dropdown list showing all collections in a given cluster, but you get the idea.
Note : Solr Admin UI shows you parsed files, so if you ever had to escape special characters, for example in a filter's regex that uses a <, you would have to re-escape it to < once you get the file back in order to prevent parse error.

I unloaded the default Solr Collection by mistake from the Solr Admin UI

How do I reload it into Solr again? If I try to launch the Solr Admin UI, I get the following message:
There are no SolrCores running.
Using the Solr Admin UI currently requires at least one SolrCore.
You will need to modify the <cores> entry in the solr.xml file that is in the root of where your Solr instance is running and add at least one <core> entry. Below is the example that comes with the Solr distribution.
<cores adminPath="/admin/cores" defaultCoreName="collection1">
<core name="collection1" instanceDir="." />
</cores>
You will need to modify this according to your local settings. You can reference more information on Cores and their settings in the CoreAdmin Solr Wiki page.
You can just run: http://127.0.0.1:8080/solr/admin/cores?action=RELOAD&core=collection1
Please note that the path and port to your solr server are correct.

Resources