I am using highlighting feature of solr. Well its doing great except one thing. Here is the problem in response
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">9</int>
</lst>
<result name="response" numFound="1" start="0" maxScore="0.6901834">
<doc>
<str name="desc">I study in school</str>
<str name="name">school</str>
<str name="value">DPS</str>
<str name="country">India</str>
<str name="state">delhi</str>
<str name="city">New Delhi</str>
<str name="area">R.K. Puram</str>
<str name="id">c02101a4-c5c2-46a9-bb73-805208167b3c</str>
<float name="score">0.6901834</float></doc>
</result>
<lst name="highlighting">
<lst name="c02101a4-c5c2-46a9-bb73-805208167b3c">
<arr name="name">
<str>school</str>
</arr>
<arr name="value">
<str><em>DP</em>S</str>
</arr>
</lst>
</lst>
</response>
In highlighting section , Why am I getting "name":"school" field ??? Even though it is not getting highlighted like "value":"DPS" ..
Thanks
Related
I am working with Solr SpellChecking.
I use the schemaless mode, default configuration is data driven and I indexed a csv file, inside the file content, there is a column Nationality, and some column values are Singapore.
Then I query spell check and I got result
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">7</int>
</lst>
<result name="response" numFound="0" start="0"></result>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="singapor">
<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">singapore</str>
<int name="freq">104</int>
</lst>
</arr>
</lst>
</lst>
<bool name="correctlySpelled">false</bool>
<lst name="collations">
<lst name="collation">
<str name="collationQuery">singapore</str>
<int name="hits">104</int>
<lst name="misspellingsAndCorrections">
<str name="singapor">singapore</str>
</lst>
</lst>
</lst>
</lst>
</response>
I want the exact result with case sensitive Singapore, not singapore.
<str name="word">Singapore</str>
I am trying to do data import handler in Solr.But not able to index the data from solr using the full_import command.It is giving a NumberFormatException even though I have defined the fields as string in schema.xml.I am using 5.2.1 version of Solr.
WARN - 2015-07-09 07:14:19.137;
[ king] org.apache.solr.handler.dataimport.SolrWriter;
Error creating document : SolrInputDocument(fields: [id=1, name=Ajay, _version_=1506201891385638912])
org.apache.solr.common.SolrException: ERROR: [doc=1] Error adding field 'name'='Ajay' msg=For input string: "Ajay"
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:176)
Can you please clarify what am I doing wrong here.When I do the same procedure in techproducts example it works fine.
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">157</int>
</lst>
<lst name="initArgs">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</lst>
<str name="command">full-import</str>
<str name="mode">debug</str>
<arr name="documents">
<lst>
<arr name="id">
<int>1</int>
</arr>
<arr name="name">
<str>Ajay</str>
</arr>
<arr name="_version_">
<long>1506202992068526080</long>
</arr>
</lst>
<lst>
<arr name="id">
<int>2</int>
</arr>
<arr name="name">
<str>Karan</str>
</arr>
<arr name="_version_">
<long>1506202992072720384</long>
</arr>
</lst>
<lst>
<arr name="id">
<int>3</int>
</arr>
<arr name="name">
<str>Raj</str>
</arr>
<arr name="_version_">
<long>1506202992077963264</long>
</arr>
</lst>
<lst>
<arr name="id">
<int>4</int>
</arr>
<arr name="name">
<str>Ramesh</str>
</arr>
<arr name="_version_">
<long>1506202992083206144</long>
</arr>
</lst>
</arr>
<lst name="verbose-output"/>
<str name="status">idle</str>
<str name="importResponse"/>
<lst name="statusMessages">
<str name="Total Requests made to DataSource">1</str>
<str name="Total Rows Fetched">4</str>
<str name="Total Documents Processed">0</str>
<str name="Total Documents Skipped">0</str>
<str name="Full Dump Started">2015-07-09 07:31:48</str>
<str name="Total Documents Failed">4</str>
<str name="Time taken">0:0:0.133</str>
</lst>
</response>
Solved this by adding _s to the string field in the data-config.xml.Solved the issue.
Using the following configuration to run the spellchecking on Solr queries:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textTitle</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">text</str>
<str name="classname">solr.DirectSolrSpellChecker</str>
<str name="distanceMeasure">internal</str>
<float name="accuracy">0.7</float>
<int name="maxEdits">2</int>
<int name="minPrefix">1</int>
<int name="maxInspections">10</int>
<int name="minQueryLength">3</int>
<float name="maxQueryFrequency">0.10</float>
<float name="thresholdTokenFrequency">.00001</float>
</lst>
</searchComponent>
<requestHandler name="standard" class="solr.StandardRequestHandler" default="true">
<!-- default values for query parameters -->
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
I get the correct suggestions for bad spelled queries, however, is it possible to re-do the query again to return the results for the spellchecked terms instead of just returning the suggestions?
When I run spellcheck query against solr on browser I can see the response with suggestions and collations, however, when I run using solr4j, I only see suggestions - no collations.
Query
http://localhost:8080/solr/peeps/mySuggest?qt=%2FmySuggest&distrib=false&df=myFieldLookup&q=myFieldLookup:sc+ma&start=0&rows=0
Response
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">3</int>
</lst>
<result name="response" numFound="0" start="0"/>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="sc">
<int name="numFound">1</int>
<int name="startOffset">32</int>
<int name="endOffset">34</int>
<arr name="suggestion">
<str>science</str>
</arr>
</lst>
<lst name="ma">
<int name="numFound">2</int>
<int name="startOffset">35</int>
<int name="endOffset">37</int>
<arr name="suggestion">
<str>management</str>
<str>master</str>
</arr>
</lst>
<lst name="collation">
<str name="collationQuery">myFieldLookup:science management</str>
<int name="hits">1</int>
<lst name="misspellingsAndCorrections">
<str name="sc">science</str>
<str name="ma">management</str>
</lst>
</lst>
<lst name="collation">
<str name="collationQuery">myFieldLookup:science master</str>
<int name="hits">1</int>
<lst name="misspellingsAndCorrections">
<str name="sc">science</str>
<str name="ma">master</str>
</lst>
</lst>
</lst>
</lst>
</response>
But when I call from solr4j, I get all of the above except the "collation" part of the response!
So, I tried this URL from browser (added wt=javabin & version) to see what solr4j is receiving.
http://localhost:8080/solr/peeps/mySuggest?qt=%2FmySuggest&distrib=false&df=myFieldLookup&q=myFieldLookup:sc+ma&start=0&rows=0&wt=javabin&version=2
which downloaded a file & I open that with text editor
£‡.responseHeader¢‡&status‡%QTimeB‡(responseÉ``ć*spellcheck°‡+suggestionsƒ‡"sc§‡(numFoundA‡+startOffsetP‡)endOffsetR‡*suggestionÅ'science‡"ma§ËBÈSÍUÎÇ*management&master‡)collation√‡.collationQuery?myFieldLookup:science management‡$hitsA‡:misspellingsAndCorrections¬Á'scienceÏ*managementÌ√Ó?myFieldLookup:science masterÔA¬Á'scienceÏ&master
It is not readable, but, I can see the word "collation" in there! So, why is Solr4j not picking it up?
You want to leverage the SolrJ SpellCheckResponse object to get access to the collation response. You should be able to see this using:
...
QueryResponse response = solr.query(params);
SpellCheckResponse spellCheckResponse = response.getSpellCheckResponse();
List<SpellCheckResponse.Collation> collations = spellCheckResponse.getCollatedResults();
I have configured my solrconfig.xml to use Suggester component as suggested in http://wiki.apache.org/solr/Suggester.
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookup</str>
<str name="field">name</str>
<!-- the indexed field to derive suggestions from -->
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<!--
<str name="sourceLocation">american-english</str>
-->
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
However, when i browse from the browser url i am not getting any suggestions.
http://localhost:8080/solr/collection1/suggest?q=ava&fq=type%3ACategory&wt=xml
<response>
<lst name="responseHeader">
<int name="status">
0
</int>
<int name="QTime">
0
</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions"/>
</lst>
</response>
Even if i remove the fq filter, I am not getting the suggestions.
Please help.
Thanks
I am not sure, can you try adding spellcheck=on
http://localhost:8080/solr/collection1/suggest?q=ava&spellcheck=on&fq=type%3ACategory&wt=xml