You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Yonik Seeley (JIRA)" <ji...@apache.org> on 2009/08/08 23:04:14 UTC

[jira] Commented: (SOLR-1071) spellcheck.extendedResults returns an invalid JSON response when count > 1

    [ https://issues.apache.org/jira/browse/SOLR-1071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740965#action_12740965 ] 

Yonik Seeley commented on SOLR-1071:
------------------------------------

bq. Why isn't this a JSONResponseWriter bug?

JSON does not require unique keys.  It's certainly a good idea though.

Donovan had it right:
bq. This seems, at least to me, like a more general issue of convention and guidelines in the search components.

It's a bad idea to repeat keys... this isn't XML.  When access-by-key is more important, use SimpleOrderedMap... when position must be maintained, use NamedList.  In both cases, we should strive not to repeat keys.

Here is what the current output is for non-extendedResults:
{code}
 <lst name="suggestions">
  <lst name="hell">
	<int name="numFound">2</int>
	<int name="startOffset">0</int>
	<int name="endOffset">4</int>
	<arr name="suggestion">
	 <str>dell</str>
	 <str>all</str>
	</arr>
  </lst>
 </lst>
{code}

The logical extension for extended results would be to simply replace each string in the array with a map.

{code}
  <lst name="hell">
	<int name="numFound">2</int>
	<int name="startOffset">0</int>
	<int name="endOffset">4</int>
	<int name="origFreq">0</int>
        <arr name="suggestion">
           <lst>
		 <int name="frequency">1</int>
  	         <str name="word">dell</str>
           </lst>
           <lst>
	         <int name="frequency">1</int>
	         <str name="word">all</str>
           </lst>
	</arr>
  </lst>
{code}

If extended results only ever added frequency, we could further simplify to have the suggest be the key and the freq be the val, but I don't know that we wouldn't want to add more metadata in the future.







> spellcheck.extendedResults returns an invalid JSON response when count > 1
> --------------------------------------------------------------------------
>
>                 Key: SOLR-1071
>                 URL: https://issues.apache.org/jira/browse/SOLR-1071
>             Project: Solr
>          Issue Type: Bug
>          Components: spellchecker
>    Affects Versions: 1.3
>            Reporter: Uri Boness
>            Assignee: Grant Ingersoll
>             Fix For: 1.4
>
>         Attachments: SpellCheckComponent_fix.patch, SpellCheckComponent_new_structure.patch, SpellCheckComponent_new_structure_incl_test.patch
>
>
> When: wt=json & spellcheck.extendedResults=true & spellcheck.count > 1, the suggestions are returned in the following format:
> "suggestions":[
> 	"amsterdm",{
> 	 "numFound":5,
> 	 "startOffset":0,
> 	 "endOffset":8,
> 	 "origFreq":0,
> 	 "suggestion":{
> 	  "frequency":8498,
> 	  "word":"amsterdam"},
> 	 "suggestion":{
> 	  "frequency":1,
> 	  "word":"amsterd"},
> 	 "suggestion":{
> 	  "frequency":8,
> 	  "word":"amsterdams"},
> 	 "suggestion":{
> 	  "frequency":1,
> 	  "word":"amstedam"},
> 	 "suggestion":{
> 	  "frequency":22,
> 	  "word":"amsterdamse"}},
> 	"beak",{
> 	 "numFound":5,
> 	 "startOffset":9,
> 	 "endOffset":13,
> 	 "origFreq":0,
> 	 "suggestion":{
> 	  "frequency":379,
> 	  "word":"beek"},
> 	 "suggestion":{
> 	  "frequency":26,
> 	  "word":"beau"},
> 	 "suggestion":{
> 	  "frequency":26,
> 	  "word":"baak"},
> 	 "suggestion":{
> 	  "frequency":15,
> 	  "word":"teak"},
> 	 "suggestion":{
> 	  "frequency":11,
> 	  "word":"beuk"}},
> 	"correctlySpelled",false,
> 	"collation","amsterdam beek"]}}
> This is an invalid json as each term is associated with a JSON object which holds multiple "suggestion" attributes. When working with a JSON library only the last "suggestion" attribute is picked up.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.