SOLR why does its state this 'leaderUrl' must be specified without the /replication suffix - solr

Why when I setup a Solr follower/slave do I get this message in the Solr logs
'leaderUrl' must be specified without the /replication suffix
This used to work fine in ersion 7.6 but now in version 8.11.1 it complains. What should the value be if not /replication?
This is the XML snippet in the solrconfig.xml that does the replications
<requestHandler name="/replication" class="solr.ReplicationHandler">
<lst name="slave">
<str name="leaderUrl">http://solr1:8983/solr/bookings/replication</str>
<str name="pollInterval">00:00:20</str>
</lst>
</requestHandler>

It seems to mean the leadUrl, I seemed to be transfixed on the name of the request handler!
So going from this which worked in 7.6
<str name="masterUrl">http://solr1:8983/solr/bookings/replication</str>
to this which works in 8.11.1
<str name="leaderUrl">http://solr1:8983/solr/bookings</str>

Related

Search suggestions in django-oscar using solr

I've setup a django-oscar project and enabled solr 4.7.2 on it as per documentation.
Solr seems to be working fine. Testing the suggestions for 'exxample' (localhost:8983/solr/collection1/spell?spellcheck.q=exxample&spellcheck=true>) I get:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">10</int>
</lst>
<result name="response" numFound="0" start="0"/>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="exxampl">
<int name="numFound">1</int>
<int name="startOffset">0</int>
<int name="endOffset">8</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
<str name="word">exampl</str>
<int name="freq">2</int>
</lst>
</arr>
</lst>
<bool name="correctlySpelled">false</bool>
<lst name="collation">
<str name="collationQuery">exampl</str>
<int name="hits">2</int>
<lst name="misspellingsAndCorrections">
<str name="exxampl">exampl</str>
</lst>
</lst>
</lst>
</lst>
</response>
I've also enabled OSCAR_SEARCH_FACETS to make sure that Solr has been correctly registered by Django-Oscar, and it seems to be working fine.
HOWEVER, when I do a test search for a simple misspelling in django-oscar, I get 0 returned search results and no suggestions. I'm not sure what to do next.
Help would be greatly appreciated!
I've managed to fix this problem. I'll write my complete solution to setting up Solr with spelling suggestions on Django-Oscar since setup procedures require adjustments from that described in the official documentation. This is also my first time working with Solr (or any search engine), so don't expect some expert guidance, just a guide on how to get Solr up and running on Oscar.
I am using Oscar 1.5 with Solr 4.7.2 (solutions also works for 4.10.4 ... not sure about other versions). Do everything as per documentations - note that there is a slight difference in instructions for versions of Oscar that are < 1.5.
Once you have Solr installed and running you can test out an inquiry on the Solr server # localhost:8983/solr/collection1/spell?spellcheck.q=[your search inquiry goes here; no brackets]&spellcheck=true>. Needs to be a word from your database - either in product description or product title.
You will get an error result saying that Analyzer needs to be of same type. Fix this by editing the solrconfig.xml file located at ./solr-4.7.2/example/solr/collection1/conf/solrconfig.xml. Search for <str name="field">, and change each non-commented instance to <str name="field">text</str> - you can also change each instance to <str name="field">title</str>, but this restricts to words found in titles only. Restart the Solr server. These changes will do away with the Analyzer error and your Solr server will now start showing results, however they won't yet be fed into your Oscar site.
To fix this you need to make another adjustment to the same solrconfig.xml file. Search for <requestHandler name="/select" class="solr.SearchHandler">, and at the bottom of this request handler include the following code:
<arr name="last-components">
<str>spellcheck</str>
</arr>
Restart the server. Now you have spelling suggestions in your Oscar site. Hope others have found this helpful. Like I said - this is the first time I'm using Solr. If someone has anything to add, or extend Solr functionality on Oscar it would be great.

Solr suggester in SolrCloud mode

I am running the solr in CloudSolr mode with three shards. The data is already indexed into solr. Now I have configured the solr suggester in solrconfig.xml. This is the configuration from solrconfig file. I am using solr 4.10 version.
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mysuggest</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="storeDir">suggester_fuzzy_dir</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">businessName</str>
<str name="payloadField">profileId</str>
<str name="weightField">businessName</str>
<str name="suggestAnalyzerFieldType">text_general</str>
<str name="buildOnStartup">false</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
Here is the command I am using to fetch the result:
http://shard1:8900/solr/core/suggest?suggest=true&suggest.build=true&suggest.reload&suggest.dictionary=mysuggest&wt=json&indent=true&suggest.q=sale
This is the output of the command:
{
"responseHeader":{
"status":0,
"QTime":1490},
"command":"build",
"suggest":{}
}
Nothing is coming into suggest result. I have 10K records indexed into solr.
I am seeing the following into log file:
org.apache.solr.handler.component.SuggestComponent; http://shard1:8983/solr/core/ : null
org.apache.solr.handler.component.SuggestComponent; http://shard2:8900/solr/core/ : null
org.apache.solr.handler.component.SuggestComponent; http://shard3:7574/solr/core/ : null
I am not able understand what is missing here. Thanks.
It was not working because solr was running in SolrCloud mode. There is two ways to perform suggestion in solrCloud mode:
Use the distrib=false parameter. This will fetch the data from only one shard which you are accessing in the command. You can add the following into Component definition itself.
<bool name="distrib">false</bool>
Use the shards and shards.qt parameter for searching all the shards. The shards parameter will contain comma separated list of all the shards which you want to include in the query. The shards.qt parameter will define the reat API you want to access.
shards.qt: Signals Solr that requests to shards should be sent to a request handler given by this parameter. Use shards.qt=/spell when making the request if your request handler is "/spell".
shards: shards=solr-shard1:8983/solr,solr-shard2:8983/solr Distributed Search
Please check Here for more details.

How to build a dictionary for spellchecking in Solr?

I'm trying to add spell checking to an existing Solr index.
I've added the following to the solrconfig.xml
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFiedlType">textSpell</str>
<lst name="spellchecker">
<str name="name">my_spell</str>
<str name="field">my_field</str>
<str name="buildOnOptimize">true</str>
<str nmae="spellcheckIndexDir">./spellchecker_my_spell</str>
</lst>
</searchComponent>
When I try to build the index with http://<myserver>:4103/my_index/select?&spellcheck=true&spellcheck.build=true&spellcheck.dictionary=cn_spell
I don't find any evidence that any dictionary is being built, either in the response, or in the file system.
What am I missing?
I forgot to add the query type to the query string. Adding &qt=dismax worked for me, since the spellcheck was the last-components of my dismax handler.

solr's suggester gives "SolrException: Unknown Search Component: spellcheck at org.apache.solr.core.SolrCore"

I tried using Solr's Suggester component but it gives exception Unknown Search Component: spellcheck. I am using solr version 3.6. I made changes in solrconfig.xml so it looks like this
<searchComponent class="solr.SpellCheckComponent" name="suggester">
<lst name="spellchecker">
<str name="name">suggester</str>
<str name="field">name</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<str name="spellcheckIndexDir">spellchecker</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggester">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggester</str>
<str name="spellcheck.count">10</str>
</lst>
<arr name="components">
<str>suggester</str>
</arr>
</requestHandler>
Now i saved it and started solr but it gives a 500 error. There is a long stack trace which goes like this
HTTP Status 500 - Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change: <abortOnConfigurationError>false</abortOnConfigurationError> in solr.xml ------------------------------------------------------------- org.apache.solr.common.SolrException: No cores were created, please check the logs for errors at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:172) at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at
---lot of lines---
and some more
Caused by: org.apache.solr.common.SolrException: Unknown Search Component: spellcheck at org.apache.solr.core.SolrCore.getSearchComponent(SolrCore.java:893) at org.apache.solr.handler.component.SearchHandler.inform(SearchHandler.java:118) at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:527) at org.apache.solr.core.SolrCore.<init>(SolrCore.java:594) ... 32 more
According to the stack trace Solr is not able to find the spellcheck component but according to the Solr wiki this component comes with Solr version > 1.4.
You seem to have named your search component suggester, and your requestHandler refers to it correctly, so that's probably not where the issue is. Can you check in the rest of your solrconfig.xml whether some other requestHandler refers to a component named spellcheck in its last-components section or elsewhere? That would throw an error since it can no longer find a component with that name (it's been renamed to suggester).
The thing with solrconfig is that it comes with a lot of preconfigured search handlers, and if you change the default name of one item it could cause issues with handlers that refer to it.

Configuring shardsWhitelist in Solr 6.6

Need help to configure shardsWhitelist in Solr 6.6. I have the below line in Solr.xml
<str name="shardsWhitelist">${solr.shardsWhitelist:}</str>
And I added the following in solrconfig.xml
<requestHandler name="/select" class="solr.SearchHandler">
<shardHandler class="HttpShardHandlerFactory">
<int name="socketTimeOut">1000</int>
<int name="connTimeOut">5000</int>
<str name="shardsWhitelist">https://<URL1>/solr/core0,<URL2>/solr/core0,<URL3>/solr/core0</str>
</shardHandler>
But, I can’t get the solr to acknowledge the configuration:
HttpShardHandlerFactory shardsWhitelist not configured but required (in lieu of ZkController and ClusterState) when using the 'shards' parameter. set -Dsolr.disable.shardsWhitelist=true to disable shards whitelist checks
Make sure to NOT use https/http.
${solr.shardsWhitelist::PORT/solr/CORENAME,:PORT/solr/CORENAME}
Example: ${solr.shardsWhitelist:something.com:8985/solr/core_0,something.com:8985/solr/core2}
You must specify the shardHandlerFactory element.
The shardHandler element is incorrect.
<requestHandler name="/select" class="solr.SearchHandler">
<shardHandlerFactory class="HttpShardHandlerFactory">
<int name="socketTimeOut">1000</int>
<int name="connTimeOut">5000</int>
<str name="shardsWhitelist"><URL1>/solr/core0,<URL2>/solr/core0,<URL3>/solr/core0</str>
</shardHandlerFactory>

Resources