Solr-Collection or Core not reloading schema.xml - solr

I am using Solar 4.6 and changed something inside schema.xml. In order to update schema.xml inside my core I used zkcli. Which works fine and I am able to see the modified schema.xml inside the Solr Admin GUI under cloud\tree\config\foobar\schema.xml.
But after calling
http://localhost:8983/solr/admin/collections?action=RELOAD&name=foobar and
http://localhost:8983/solr/admin/cores?action=RELOAD&name=foobar,
the old schema.xml was still in the core named foobar.

Your 2nd HTTP request to the Core API is wrong. Change name to core:
http://localhost:8983/solr/admin/cores?action=RELOAD&name=foobar should be
http://localhost:8983/solr/admin/cores?action=RELOAD&core=foobar.
http://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-4.6.pdf (page 277)
RELOAD
The RELOAD action loads a new core from the configuration of an existing, registered Solr core. While the new core is initializing, the existing one
will continue to handle requests. When the new Solr core is ready, it takes over and the old core is unloaded.
This is useful when you've made changes to a Solr core's configuration on disk, such as adding new field definitions. Calling the RELOAD action
lets you apply the new configuration without having to restart the Web container. However the Core Container does not persist the SolrCloud
solr.xml parameters, such as solr/#zkHost and solr/cores/#hostPort, which are ignored.
http://localhost:8983/solr/admin/cores?action=RELOAD&core=core0
The RELOAD action accepts a single parameter, core, which is the name of the core to be reloaded.
see also https://cwiki.apache.org/confluence/display/solr/CoreAdmin+API#CoreAdminAPI-RELOAD

You have to reload your cores after giving it a new schema.
Replace name with core in your query as:
/solr/admin/cores?action=RELOAD&**core**=yourcorename
For example
http://localhost:8983/solr/admin/cores?action=RELOAD&core=foobar

Related

Can I query a new handler not in solr config?

I am using solr 5.4.0.
I want to create a new handler in solr say "X". This handler is not defined in solr config, but can I define this on run time and include it in query using the qt field?
The same way how we can replace the bq, qf etc fields for an already existing handler in solr config, is there a support for creating a new handler while issuing the solr query as well
I do not remember being able to create additional request handlers via API in Solr 5.4. You may be able to modify or XInclude a file on a filesystem and reload core. But that's a bit hacky.
In the latest versions of Solr, you do have
configuration API to override solrconfig.xml
request parameters API, that allow you to define parameter sets, which you can apply with useParams configuration or as a query parameter in the URL.

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.

Solr - Active/Passive mode for data core and deleting stale data

We get a feed file nightly which is loaded to Solr through "update" API (http://localhost:8983/solr/data_core/update?stream.file=). We can only data stale data once current file is successfully loaded to Solr.
Currently, we are using Solr 6.1.0 in our development phase, so we have setup with 2 Shards and replication factor as 2.
Question
How can we have active/passive instance of SOlr core while active instance (with stale data) is open to business, we can load data from file to passive instance and once the load of file is successful switch the active instance to new one?
Thanks,
You can create a new core with the same schema and config as your current one (data_core). Let's call it data_core2.
Then your nightly update process can load this one and, after completion of this process, you can use the APIs to swap between the two cores, this way:
http://localhost:8983/solr/admin/cores?action=SWAP&core=data_core&other=data_core2
data_core will be available for searches during the whole time

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.

Resources