Custom UpdateRequestProcessorFactory - solr

I have written a custom UpdateRequestProcessorFactory to parse my data before getting indexed. But the data is not getting committed. So when i restart the server all the data is gone. I have used the correct config also.
<updateRequestProcessorChain name="mytestupdatehandler" default="true">
<processor class="com.solr.handler.interceptor"></processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
<requestHandler name="/MypdateHandler" class="solr.UpdateRequestHandler" >
<lst name="defaults">
<str name="update.chain">mytestupdatehandler</str>
</lst>
</requestHandler>
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<!-- See below for information on defining
updateRequestProcessorChains that can be used by name
on each Update Request
-->
<lst name="defaults">
<str name="maxThreads">50</str>
<str name="handlerType">asyncXML</str>
<str name="sharedError">false</str>
</lst>
</requestHandler>
Also the default update handler also uses my update.chain . how to prevent that

You have default="true", so that makes your chain used for all update handlers. Remove that.
You seem to be missing class name in your handler definition, unless it is interceptor in the com.solr.handler package: <processor class="com.solr.handler.interceptor.CLASSNAME?"></processor>
Are you getting any errors in the console log if you start Solr from the command line? That might give you a hint.

Related

Solr Error: QueryComponent.mergeIds(QueryComponent.java:895) in custom request handler

I'm using Solr 8.4.0 and i tried to make a search request handler that only return a specific sets of field in a collection, without anyone can change what fields to be displayed.
Here is how the request handler looks like
<requestHandler class="solr.SearchHandler" name="/search">
<arr name="components">
<str>query</str>
<str>facet</str>
</arr>
<lst name="defaults">
<int name="rows">10</int>
<str name="wt">json</str>
<str name="q.alt">*:*</str>
</lst>
<lst name="invariants">
<str name="facet">true</str>
<str name="facet.mincount">1</str>
<str name="fl">_uniqueid</str>
<str name="fl">document_title_t</str>
<str name="fl">document_title_string_s</str>
<str name="fl">document_shortsummary_t</str>
<str name="fl">page_url_s</str>
<str name="fl">topic_path</str>
<str name="fl">itemid_s</str>
<str name="echoParams">none</str>
<str name="omitHeader">true</str>
</lst></requestHandler>
After making the collection and trying the request handler, i received
this error
It seems this issue only happens when we are using multiple shards, changing the collection to a single shard removes the error, but we need to have multiple shards for this collection later on production. We are using 2 shards and 3 replicas
I have managed to solve this issue. By going through solr's code from repository in github, i found out that at queryComponent.java line 895 it's trying to access a certain header. After removing the omitHeader invariant the request handler seems to work perfectly

/browse handler (velocity UI) not initiating CustomQueryParser

I have defined my CustomQueryParser in my RequestHandler.
Below is the RequestHandler part of the code in solrconfig.xml
<requestHandler name="/browse" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">customparser</str>
<str name="echoParams">explicit</str>
<str name="qf">body_txt manu2</str>
<str name="q.op">AND</str>
<!-- <str name="mm">100%</str> -->
</lst>
</requestHandler>
And below is the queryParser part of the code in solrconfig.xml
<queryParser name="customparser" class="com.mycompany.lucene.search.QueryParserPlugin"/>
I have ensured that the jar file associated to the QueryParserPlugin is loading.
But when I make a query the correct documents are not reflecting.
Is there a way I can print from within my CustomQueryParser jar to the solr.log to know if it is being invoked?
Also how do i get this to work?
Have been struggling with this since quite a few days. Please Help !
Thanks

Solr auto suggest (suggester) returns no results

I am quite new to using solr5.1 - and I am now playing around to see if I can get the autosuggest to work. So, the background is that I have a core named docs and I post documents to this collection using something along the lines of:
/bin/post -c docs /path/to/my/docs/*.pdf
..and I have the documents indexed. Now, I tweak the solrconfig.xml, located within my core directory to include autosuggest. So, borrowing some code from here, I include the following:
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="storeDir">suggester_fuzzy_dir</str>
<!-- Substitute these for the two above for another "flavor"
<str name=”lookupImpl”>AnalyzingInfixLookupFactory</str>
<str name=”indexPath”>suggester_infix_dir</str>
-->
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">_text_</str>
<str name="suggestAnalyzerFieldType">string</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">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>
<str name="suggest.dictionary">mySuggester</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
Now, I do:
http://localhost:8983/solr/docs/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&wt=json&suggest.q=mode
and I always seem to get:
{"responseHeader":
{"status":0,"QTime":19},
"command":"build","suggest":
{"mySuggester":
{"mode":
{"numFound":0,"suggestions":[]}
}
}
}
I am not entirely sure what is it that I am doing wrong - I was wondering if I should be modifying the solrconfig.xml before adding any docs? or was it something wrong with the snippet of code inserted into it? Also, I am not sure if this line:
<str name="suggestAnalyzerFieldType">string</str>
is correct. I read that use of string should not be used - but again, I see the solr docs using it.
I have also tried code from here, but it seems to give me the same results - i.e no suggested words.
Any help on this would be great.
UPDATE: #01:
I have recently been reading that some features of solr need stored=true to work. I am now wondering if this applies to Suggester. So, do I need to turn the text field in solr.xml to stored=true?

How to query Solr shard

I've followed this to set up shard in Solr. As per this topic "Testing Index Sharding on Two Local Servers", I was able to query into shard and get the result (somehose:port1/solr/select?shards=somehost:port1/solr,somehost:port2/solr&indent=true&q=helloworld
).
In that page it is also mentioned that "Rather than require users to include the shards parameter explicitly, it is usually preferred to configure this parameter as a default in the RequestHandler section of solrconfig.xml."
So, I made the changes in solrconfig.xml of the solr instance which is running on port1
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
</lst>
<lst name="shards.info">
<lst name="localhost:port2/solr">
<long name="numFound">1333</long>
<float name="maxScore">1.0</float>
<str name="shardAddress">http://localhost:port2/solr</str>
<long name="time">686</long>
</lst>
<lst name="localhost:port1/solr">
<long name="numFound">342</long>
<float name="maxScore">1.0</float>
<str name="shardAddress">http://localhost:port1/solr</str>
<long name="time">602</long>
</lst>
</lst>
Now, I'm trying to hit somehost:port1/solr/collection1/select?q=helloworld&wt=json&indent=true
but I'm not getting the desired responce. Please let me know what I'm missing here?
You can't just copy the content from the response into your configuration file - those two formats are completely different. The reference is to the fact that each entry in the defaults section is added to the query string (unless they're provided there already - there are also options if you want to force a certain value that can't be overridden).
<requestHandler name="/selectdistributed" class="solr.SearchHandler">
<lst name="defaults">
[...]
<str name="shards">somehost:port1/solr,somehost:port2/solr</str>
</lst>
</requestHandler>
.. should do what you want. This will add shards=somehost:port1/solr,somehost:port2/solr to the query string of all the requsts that go through that handler.

Solr and spellcheck component : spellcheck.q doesn't take into consideration

I use spellcheck component and when I request solr I have results. But if I use spellcheck.q, i haven't result.
Someone has an idea ?
Thanks
<!-- The spell check component can return a list of alternative spelling
suggestions. -->
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">spellCheck</str>
<str name="spellcheckIndexDir">./spellchecker</str>
<str name="buildOnCommit">true</str>
<str name="accuracy">0.4</str>
<float name="thresholdTokenFrequency">.0004</float>
</lst>
</searchComponent>
<!--<queryConverter name="queryConverter" class="solr.SpellingQueryConverter"/>-->
<!-- Handler par défaut -->
<requestHandler name="default" class="solr.SearchHandler" lazy="true" default="true">
<lst name="defaults">
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">10</str>
<str name="hl.usePhraseHighLighter">true</str>
<str name="hl.highlightMultiTerm">true</str>
<str name="hl.mergeContiguous">true</str>
</lst>
<arr name="last-components">
<str>highlight</str>
<str>spellcheck</str>
</arr>
</requestHandler>
Have you added your spellcheck component to the corresponding request handler (in solr config), set spellcheck parameter to true (or on) and configured the correct dictionary to use (if its name different than "default")?
If you don't use the spellcheck.q parameter, then the default is to use the q parameter (from http://wiki.apache.org/solr/SpellCheckComponent#q_OR_spellcheck.q). From that wiki:
Essentially, if you have a spelling "ready" version in your application, then it is probably better to send spellcheck.q, otherwise, if you just want Solr to do the job, use the q parameter
The reason that it works if you change the definition of the field type is probably due to the new field type being "spelling ready". It would help if you posted the query you are using and the relevant lines in the schema.xml.

Resources