I wrote a small client in .Net which query Solr and dumps the result on
screen.. fantastic low-tech.. ;)
However I ran into new SolrSharp problems. My schema allows a particular
field to be multiValued, but if it only has one value, it will cause
SolrSharp fail in line 88 of Class: IndexFiledAttribute.
My SearchRecord property is an array (List) and line 88 tries to set my
property as if it was a string. The code should be corrected by checking
if the property is an array and not whether it has 1 value or more.
E.g. change line 85 to 085> if(!this.PropertyInfo.PropertyType.IsArray)
Original code (from class IndexFiledAttribute):
082> public void SetValue(SearchRecord searchRecord)
083> {
084> XmlNodeList xnlvalues =
searchRecord.XNodeRecord.SelectNodes(this.XnodeExpression);
085> if (xnlvalues.Count == 1) //single value
086> {
087> XmlNode xnodevalue = xnlvalues[0];
088> this.PropertyInfo.SetValue(searchRecord,
Convert.ChangeType(xnodevalue.InnerText, this.PropertyInfo.PropertyType)
, null);
089> }
090> else if (xnlvalues.Count > 1) //array
091> {
092> Type basetype =
this.PropertyInfo.PropertyType.GetElementType();
093> Array valueArray = Array.CreateInstance(basetype,
xnlvalues.Count);
094> for (int i = 0; i < xnlvalues.Count; i++)
095> {
096>
valueArray.SetValue(Convert.ChangeType(xnlvalues[i].InnerText,
basetype), i);
097> }
098> this.PropertyInfo.SetValue(searchRecord, valueArray, null);
099> }
100> }
My code (replace):
085> if(!this.PropertyInfo.PropertyType.IsArray) // single value
090> else // array
Cheers,
Peter Thygesen
-- hope to see you all at ApacheCon in Amsterdam :)