Ups. Forgot to tell that the patch was uploaded on CodePlex
http://www.codeplex.com/solrsharp/SourceControl/PatchList.aspx

\peter


-----Original Message-----
From: Peter Thygesen 
Sent: 25. januar 2008 13:17
To: solr-user@lucene.apache.org
Subject: RE: Getting SolrSharp to work, Part 2

This patch covers the issues I wrote about in my previous mails "How to
get SolrSharp to work" and "How to get SolrSharp to work, part 2" 

By the way should I post on this thread, or on CodePlex. When the topic
is "SolrSharp"? I don't mind adding a few more comments to the
discussion I already started on CodePlex.

\peter

-----Original Message-----
From: Jeff Rodenburg [mailto:[EMAIL PROTECTED] 
Sent: 24. januar 2008 20:59
To: solr-user@lucene.apache.org
Subject: Re: Getting SolrSharp to work, Part 2

Hey Peter - if you could submit your changes as an svn patch, we could
apply
the update much faster.

thanks,
jeff



On Jan 23, 2008 2:42 AM, Peter Thygesen <[EMAIL PROTECTED]> wrote:

> 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 :)
>
>
>




Reply via email to