RE: Getting SolrSharp to work, Part 2

2008-01-25 Thread Peter Thygesen
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):
 085if(!this.PropertyInfo.PropertyType.IsArray) // single value
 090else // array

 Cheers,
 Peter Thygesen

 -- hope to see you all at ApacheCon in Amsterdam :)







Re: Getting SolrSharp to work, Part 2

2008-01-25 Thread Chris Hostetter
: Great, thanks Peter.  And yes, I think it would be good to concentrate the
: conversation over on codeplex.  I know the Solr team has no problem with
: solrsharp conversations here on the solr mailing list, but the conversation
: is highly focused on the server.  Putting the solrsharp conversation on
: codeplex would keep the messages from drowning on this list.

no problem with solrsharp conversations is an understatement .. users
should feel free to discuss any and all issues relating to using Solr on 
the solr-user list.

That said: if there are client (or plugin) projects that have 
non-apache homes and those homes have their own discussion / issue 
tracking systems then by all means use those as appropriate.

Overwellming volume on the solr-user list because of all the people 
talking about the the SolrSharp client is hte kind of problem i'd love to 
have :)


-Hoss



RE: Getting SolrSharp to work, Part 2

2008-01-25 Thread Peter Thygesen
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):
 085if(!this.PropertyInfo.PropertyType.IsArray) // single value
 090else // array

 Cheers,
 Peter Thygesen

 -- hope to see you all at ApacheCon in Amsterdam :)









Re: Getting SolrSharp to work, Part 2

2008-01-25 Thread Jeff Rodenburg
Great, thanks Peter.  And yes, I think it would be good to concentrate the
conversation over on codeplex.  I know the Solr team has no problem with
solrsharp conversations here on the solr mailing list, but the conversation
is highly focused on the server.  Putting the solrsharp conversation on
codeplex would keep the messages from drowning on this list.

I'll check out the patch when I get a chance, thanks for the contribution.
Hope things are working better for you now.  :-/

-- j

On Jan 25, 2008 4:53 AM, Peter Thygesen [EMAIL PROTECTED] wrote:

 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):
  085if(!this.PropertyInfo.PropertyType.IsArray) // single value
  090else // array
 
  Cheers,
  Peter Thygesen
 
  -- hope to see you all at ApacheCon in Amsterdam :)
 
 
 







Getting SolrSharp to work, Part 2

2008-01-23 Thread Peter Thygesen
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):
085if(!this.PropertyInfo.PropertyType.IsArray) // single value
090else // array

Cheers, 
Peter Thygesen

-- hope to see you all at ApacheCon in Amsterdam :)