Version solrsharp-Dec-30-2007.zip
I had to make a few changes to get this version to work. Here is what I did.
------------------------------
// fix 1,. Solr server messed up Danish/Norwegian letters like "æøå" because
the HttpWbRequest object wasn't sending in utf-8 to Solr server
Class: SolrSearcher,
Method: public static HttpStatusCode WebPost(string url, byte[] bytesToPost,
ref string statusDescription)
Changed line
oRequest.ContentType = "text/xml";
To
oRequest.ContentType = "text/xml;charset=\"utf-8\"";
-----------------------------
// fix 2, Could not get Schema.xml from server.. Permission denied.. or wrong
URL.
Class SolrSearcher,
Method private void SetSolrPaths()
Changed
this.SOLR_CONFIG = this.SOLR + "admin/get-file.jsp?file=solrconfig.xml";
To
this.SOLR_CONFIG = this.SOLR + "admin/file/?file=solrconfig.xml";
this.SOLR_SCHEMA = this.SOLR + "admin/get-file.jsp?file=schema.xml";
To
this.SOLR_SCHEMA = this.SOLR + "admin/file/?file=schema.xml";
---------------------------
// fix 3,. Added functionality. My schema had field with required=false and the
validation failed.
// if (solrService.SolrSchema.IsValidUpdateIndexDocument(doc)) // failed
//
1)
Class: SolrField
Method: public SolrField(XmlNode xnSolrField, SolrSchema solrSchema)
At Last line:
Before:
this.solrschema = solrschema;
After:
if (xnSolrField.Attributes["required"] != null)
{
this.required =
Convert.ToBoolean(xnSolrField.Attributes["required"].Value);
}
this.solrschema = solrSchema;
2) Added Property getter in SolrField class
private bool required = false;
public bool IsRequired
{
get { return this.required; }
}
3)
Add check for IsRequired in field loop
Class: SolrSchema
Method: public bool IsValidUpdateIndexDocument(UpdateIndexDocument
updateIndexDocument)
{
....
foreach (SolrField solrField in this.solrFields)
{
if ((!solrField.IsCopied) &&
(!solrField.IsDefaulted) &&
(!docfieldnames.Contains(solrField.Name) &&
solrField.IsRequired) // ADDED by Peter Thygesen
)
{
return false;
}
else
{
docfieldnames.Remove(solrField.Name);
}
}
....
}
--------------------------------
// fix 4:
// removed unnecessary namespace declarations in posted xml
Class: IndexDocument
Method: public string SerializeToString()
After XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
Add line:
xsn.Add("", "");
Hope someone can use this.. I took me all day to figure out.
\Peter Thygesen