user2023507
user2023507

Reputation: 1183

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?

Upvotes: 0

Views: 220

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

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

Upvotes: 0

Related Questions