mfares / solrpy

Automatically exported from code.google.com/p/solrpy
0 stars 0 forks source link

Parser problems with collation nodes #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The parse_query_response function fail at parsing a Solr response that include 
more than one collation (i.e. search query suggestions - see 
http://wiki.apache.org/solr/SpellCheckComponent) : only the last collation 
appear in the parsed response. My guess is that you store the parsed nodes by 
name somehow, but the collation nodes as returned by solr having the same name, 
each parsed node override the previous one, thus only the last one appear in 
the parsed response. Instead, you should accumulate the nodes in a list.

See the solr response attached to this bug : the xml response has 10 collation 
nodes, but only the last one appear in the parsed response

Solr version : Solr Implementation Version: 3.6.1 1362471 - thetaphi - 
2012-07-17 12:45:52
Solrpy version : 0.9.5

Original issue reported on code.google.com by sylvain....@gmail.com on 19 Oct 2012 at 9:54

Attachments:

GoogleCodeExporter commented 8 years ago
This is due to lines 1034-1037 in solr/core.py efe41f9275a0, where any named 
list structure is loaded into a Python dict. Named Lists are unlike dicts in 
that they may have multiple values for the same key and -- at least for the 
purposes of representation as XML -- are ordered.

So here are possible solutions for solrpy:
* Always load named lists (<lst>) into some new container, which by default 
acts like a dict with single values, but has additional functions to get all 
values for a particular name. This will make the current functionality a bit 
less efficient.
* Specially handle the spellcheck response and other cases that require 
multivalue support. Or vice-versa.

Original comment by joel.nothman@gmail.com on 28 Oct 2012 at 4:56