About Suggester component - solr

I am a newbie in solr. Recently I have installed solr 3.4 for my undergrad thesis purpose. I have tried to configure suggester component by the reference of http://solr.pl/en/2010/11/15/solr-and-autocomplete-part-2/
it did not give me the actual result after following all instruction and code.
after query http://localhost:8983/solr/suggest?q=har I got
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">32</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions"/>
</lst>
</response>
Where the actual one was
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="dys">
<int name="numFound">4</int>
<int name="startOffset">0</int>
<int name="endOffset">3</int>
<arr name="suggestion">
<str>hard drive</str>
<str>hard drive samsung</str>
<str>hard drive seagate</str>
<str>hard drive toshiba</str>
</arr>
</lst>
</lst>
</lst>
</response>
I am assuming that I am not getting the suggestion .
I dont know whether am I wrong or not . It will be very helpful for me if someone clear my confusion and how could I approach further if I am wrong.

Did you build the dictionary? And does the name_autocomplete field actually hold the example data?

Related

Solr Spell Checking returns suggestions with exact match, case sensitive

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>

org.apache.solr.search.SyntaxError: on SOLR Multi-select Facet Query

I am trying to debug an issue that I am having with the following query:
q=(Cartridge)&fq={!tag=Deals_EN_ss}Deals_EN_ss:"Clearance%20Items"%20OR%20{!tag=Deals_EN_ss}Deals_EN_ss:"On%20Promotion"&defType=edismax&facet=true&facet.field={!ex=Deals_EN_ss}Deals_EN_ss&facet.field={!key=Brand_EN_ss}Brand_EN_ss&facet.field={!key=Rating_EN_ss}Rating_EN_ss&facet.field={!key=CA_Default_Price_EN_p}CA_Default_Price_EN_p
Here, I am trying to perform a multi-select facet query, filtering on the Deals_EN_ss facet. When I run this query against my SOLR server. I get the following response back:
<response>
<lst name="responseHeader">
<int name="status">400</int>
<int name="QTime">3</int>
<lst name="params">
<str name="facet">true</str>
<str name="q">(Cartridge)</str>
<arr name="facet.field">
<str>{!ex=Deals_EN_ss}Deals_EN_ss</str>
<str>{!key=Brand_EN_ss}Brand_EN_ss</str>
<str>{!key=Rating_EN_ss}Rating_EN_ss</str>
<str>{!key=CA_Default_Price_EN_p}CA_Default_Price_EN_p</str>
</arr>
<str name="wt">xml</str>
<arr name="fq">
<str>
{!tag=Deals_EN_ss}Deals_EN_ss:"Clearance Items" OR {!tag=Deals_EN_ss}Deals_EN_ss:"On Promotion"
</str>
</arr>
<str name="defType">edismax</str>
</lst>
</lst>
<lst name="error">
<str name="msg">
org.apache.solr.search.SyntaxError: Cannot parse 'Deals_EN_ss:"On': Lexical error at line 1, column 16. Encountered: <EOF> after : "\"On"
</str>
<int name="code">400</int>
</lst>
</response>
I am not sure what I am missing here. Can anyone please help me look into the query syntax?
Tags and excludes are specified as local params {!...}, which can only occure once at the start of each parameter.
See https://wiki.apache.org/solr/LocalParams
Your first fq parameter contains a second illegal local param.
Try to remove the second occurance of {!tag=Deals_EN_ss}.
Your query should look like this then:
q=(Cartridge)&fq={!tag=Deals_EN_ss}Deals_EN_ss:"Clearance%20Items"%20OR%20Deals_EN_ss:"On%20Promotion"&defType=edismax&facet=true&facet.field={!ex=Deals_EN_ss}Deals_EN_ss&facet.field={!key=Brand_EN_ss}Brand_EN_ss&facet.field={!key=Rating_EN_ss}Rating_EN_ss&facet.field={!key=CA_Default_Price_EN_p}CA_Default_Price_EN_p

Solr4j & Collation response

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();

Make Solr automatically search by first suggestion in spell correction

We're trying to use Solr to correct the spelling of certain tests in a search box. We found that it works like this:
http://localhost:8080/solr/collection1/spell?q=badspelled&spellcheck=true
And it returns a set of suggested terms. But what we need is not a list of suggestions but that Solr makes a search directly using the first suggestion. Is that possible?
You will need to add the "spellcheck.collate=true" parameter to your first search query and then use the "collation" value in the response to fire a second query with that value.
Example from the plugin page:
http://localhost:8983/solr/spell?q=price:[80 TO 100] delll ultrashar&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true
This returns the suggestions:
<lst name="spellcheck">
<lst name="suggestions">
<lst name="delll">
<int name="numFound">1</int>
<int name="startOffset">18</int>
<int name="endOffset">23</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
<str name="word">dell</str>
<int name="freq">2</int>
</lst>
</arr>
</lst>
<lst name="ultrashar">
<int name="numFound">1</int>
<int name="startOffset">24</int>
<int name="endOffset">33</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
<str name="word">ultrasharp</str>
<int name="freq">2</int>
</lst>
</arr>
</lst>
<bool name="correctlySpelled">false</bool>
<str name="collation">price:[80 TO 100] dell ultrasharp</str>
</lst>
</lst>
Then fire another query with the suggested query:
http://localhost:8983/solr/spell?q=price:[80 TO 100] dell ultrasharp&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true
SpellCheck collate

Solr: I have set `hl=true` but no summaries are being output

I need to get snippets from documents where the query terms are matched to be able to output results similar to Google's snippet beneath the website URL. For example:
Snippet - Wikipedia, the free encyclopedia
en.wikipedia.org/wiki/Snippet
A snippet is defined as a small piece of something, it may in more specific contexts refer to: Sampling (music), the use of a short phrase of a recording as an ...
I have set hl=true and even hl.fl='*' in the query URL and but no summaries are being output.
Solr FAQs say:
For a field to be summarizable it must be both stored and indexed.
I'm using Nutch and Solr and have set them up using this tutorial. What additional steps to I need to take to be able to do this?
Adding sample query and output:
http://localhost:8983/solr/select/?q=test&version=2.2&start=0&rows=10&indent=on&hl=true
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">57</int>
<lst name="params">
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">test</str>
<str name="hl">true</str>
<str name="version">2.2</str>
<str name="rows">10</str>
</lst>
</lst>
<result name="response" numFound="94" start="0">
<doc>
<arr name="anchor">
<str>User:Sir Lestaty de Lioncourt</str>
</arr>
<float name="boost">0.0</float>
<str name="digest">6c27160d0b08068f3873bb2c063508b3</str>
<str name="id">
http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt
</str>
<str name="segment">20111029223245</str>
<str name="title">User:Sir Lestaty de Lioncourt - Wikibooks</str>
<date name="tstamp">2011-10-29T21:34:27.055Z</date>
<str name="url">
http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt
</str>
</doc>
...
</result>
<lst name="highlighting">
<lst name="http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt"/>
<lst name="http://aa.wikipedia.org/wiki/User:PipepBot"/>
<lst name="http://aa.wikipedia.org/wiki/User:Purodha"/>
...
</lst>
</response>
Looks like you aren't specifying the field to highlight (hl.fl). You should create a text field to use for highlighting (don't use string type) and have it stored/indexed.

Resources