Re: SolrSharp example
Hi Michael - Moving this conversations to the general solr mailing list... 1. SolrSharp example solution works with schema.xml from apache-solr-1.1.0-incubating.If I'm using schema.xml from apache-solr-1.2.0 example program doesn't update index... I didn't realize the solr 1.2 release code sample schema.xml was different from the solr 1.1 version. In my implementation, I had solr 1.1 already installed and upgraded to 1.2 by replacing the war file (per the instructions in solr.) So, the example code is geared to go against the 1.1schema. For the example code, adding the timestamp field in the ExampleIndexDocument public constructor such as: this.Add(new IndexFieldValue(timestamp, DateTime.Now.ToString (s)+Z))); will take care of the solr 1.2 schema invalidation issue. The addition of the @default attribute on this field in the schema is not presently accommodated in the validation routine. If I'm not mistaken, the default attribute value will be applied for all documents without that field present in the xml payload. This would imply that any field with a default attribute is not required for any implemented UpdateIndexDocument. I'll look into this further. 2. When I run example with schema.xml from apache-solr-1.1.0-incubating program throw Exception Hmmm, can't really help you with this one. It sounds as if solr is incurring an error when the xml is posted to the server. Try the standard step-through troubleshooting routines to see what messages are being passed back from the server. -- j On 6/19/07, Michael Plax [EMAIL PROTECTED] wrote: Hello Jeff, thank you again for updating files. I just run with some problems. I don't know what is the best way to report them solr maillist/solrsharp jira. 1. SolrSharp example solution works with schema.xml from apache-solr-1.1.0-incubating. If I'm using schema.xml from apache-solr-1.2.0 example program doesn't update index because: line 33: if (solrSearcher.SolrSchema.IsValidUpdateIndexDocument(iDoc)) return false. update falls because of configuration file schema.xml file: line 265: field name=word type=string indexed=true stored=true/ ... line 279:field name=timestamp type=date indexed=true stored=true default=NOW multiValued=false/ those fields word, timestamp don't pass validation in SolrSchema.csline 217. 2. When I run example with schema.xml from apache-solr-1.1.0-incubating program throw Exception System.Exception was unhandled Message=Http error in request/response to http://localhost:8983/solr/update/; Source=SolrSharp StackTrace: at org.apache.solr.SolrSharp.Configuration.SolrSearcher.WebPost(String url, Byte[] bytesToPost, String statusDescription) in E:\SOLR-CSharp\src\Configuration\SolrSearcher.cs:line 229 at org.apache.solr.SolrSharp.Update.SolrUpdater.PostToIndex(IndexDocument oDoc, Boolean bCommit) in E:\SOLR-CSharp\src\Update\SolrUpdater.cs:line 70 at SolrSharpExample.Program.Main(String[] args) in E:\SOLR-CSharp\example\Program.cs:line 35 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly () at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() xmlstring value from oDoc.SerializeToString() ?xml version=\1.0\ encoding=\utf-8\?add xmlns:xsi=\ http://www.w3.org/2001/XMLSchema-instance\http://www.w3.org/2001/XMLSchema-instance%5C xmlns:xsd=\http://www.w3.org/2001/XMLSchema\;docfieldhttp://www.w3.org/2001/XMLSchema%5C%22%3E%3Cdoc%3E%3Cfieldname=\id\101/fieldfield name=\name\One oh one/fieldfield name=\manu\Sony/fieldfield name=\cat\Electronics/fieldfield name=\cat\Computer/fieldfield name=\features\Good/fieldfield name=\features\Fast/fieldfield name=\features\Cheap/fieldfield name=\includes\USB cable/fieldfield name=\weight\1.234/fieldfield name=\price\99.99/fieldfield name=\popularity\1/fieldfield name=\inStock\True/field/doc/add I checked all features from Solr tutorial, they are working. I'm running solr on Windows XP Pro without firewall. Do you know how to solve those problems? Do you recommend to handle all communication by maillist/jira ? Regards Michael
Re: SolrSharp example
On 6/20/07, Yonik Seeley [EMAIL PROTECTED] wrote: On 6/20/07, Michael Plax [EMAIL PROTECTED] wrote: This is a log that I got after runnning SolrSharp example. I think example program posts not properly formatted xml. I'm running Solr on Windows XP, Java 1.5. Are those settings could be the problem? Solr1.2 is pickier about the Content-type in the HTTP headers. I bet it's being set incorrectly. Ahh, good point. Within SolrSearcher.cs, the WebPost method contains this setting: oRequest.ContentType = application/x-www-form-urlencoded; Looking through the CHANGES.txt file in the 1.2 tagged release on svn: 9. The example solrconfig.xml maps /update to XmlUpdateRequestHandler using the new request dispatcher (SOLR-104). This requires posted content to have a valid contentType: curl -H 'Content-type:text/xml; charset=utf-8'. The response format matches that of /select and returns standard error codes. To enable solr1.1 style /update, do not map /update to any handler in solrconfig.xml (ryan) For SolrSearcher.cs, it sounds as though changing the ContentType setting to text/xml may fix this issue. I don't have a 1.2 instance to test this against available to me right now, but can check this later. Michael, try updating your SolrSearcher.cs file for this content-type setting to see if that resolves your issue. thanks, jeff r.
Re: SolrSharp example
Hello, Yonik and Jeff thank you for your help. You are right this was content-type issue. in order to run example following things need to be done: 1.Code (SolrSharp) should be changed from: src\Configuration\SolrSearcher.cs(217):oRequest.ContentType = application/x-www-form-urlencoded; to: src\Configuration\SolrSearcher.cs(217):oRequest.ContentType = text/xml; 2. In order take care of the solr 1.2 schema invalidation issue: schema.xml comment line: 265 !-- field name=word type=string indexed=true stored=true/-- comment line: 279 !-- field name=timestamp type=date indexed=true stored=true default=NOW multiValued=false/-- or as Jeff suggested: For the example code, adding the timestamp field in the ExampleIndexDocument public constructor such as: this.Add(new IndexFieldValue(timestamp, DateTime.Now.ToString(s)+Z))); Regards Michael - Original Message - From: Jeff Rodenburg [EMAIL PROTECTED] To: solr-user@lucene.apache.org Sent: Wednesday, June 20, 2007 1:56 PM Subject: Re: SolrSharp example On 6/20/07, Yonik Seeley [EMAIL PROTECTED] wrote: On 6/20/07, Michael Plax [EMAIL PROTECTED] wrote: This is a log that I got after runnning SolrSharp example. I think example program posts not properly formatted xml. I'm running Solr on Windows XP, Java 1.5. Are those settings could be the problem? Solr1.2 is pickier about the Content-type in the HTTP headers. I bet it's being set incorrectly. Ahh, good point. Within SolrSearcher.cs, the WebPost method contains this setting: oRequest.ContentType = application/x-www-form-urlencoded; Looking through the CHANGES.txt file in the 1.2 tagged release on svn: 9. The example solrconfig.xml maps /update to XmlUpdateRequestHandler using the new request dispatcher (SOLR-104). This requires posted content to have a valid contentType: curl -H 'Content-type:text/xml; charset=utf-8'. The response format matches that of /select and returns standard error codes. To enable solr1.1 style /update, do not map /update to any handler in solrconfig.xml (ryan) For SolrSearcher.cs, it sounds as though changing the ContentType setting to text/xml may fix this issue. I don't have a 1.2 instance to test this against available to me right now, but can check this later. Michael, try updating your SolrSearcher.cs file for this content-type setting to see if that resolves your issue. thanks, jeff r.
Re: SolrSharp example
Thanks for checking, Michael -- great find. I'm in process of readying this same fix for inclusion in the source code (I'm verifying against a full 1.2install.) The SolrField class is now also being extended to incorporate an IsDefaulted property, which will permit the SolrSchema.IsValidUpdateIndexDocument to yield true when default value fields aren't present in the update request. thanks, jeff r. On 6/20/07, Michael Plax [EMAIL PROTECTED] wrote: Hello, Yonik and Jeff thank you for your help. You are right this was content-type issue. in order to run example following things need to be done: 1.Code (SolrSharp) should be changed from: src\Configuration\SolrSearcher.cs(217):oRequest.ContentType = application/x-www-form-urlencoded; to: src\Configuration\SolrSearcher.cs(217):oRequest.ContentType = text/xml; 2. In order take care of the solr 1.2 schema invalidation issue: schema.xml comment line: 265 !-- field name=word type=string indexed=true stored=true/-- comment line: 279 !-- field name=timestamp type=date indexed=true stored=true default=NOW multiValued=false/-- or as Jeff suggested: For the example code, adding the timestamp field in the ExampleIndexDocument public constructor such as: this.Add(new IndexFieldValue(timestamp, DateTime.Now.ToString(s)+Z))); Regards Michael - Original Message - From: Jeff Rodenburg [EMAIL PROTECTED] To: solr-user@lucene.apache.org Sent: Wednesday, June 20, 2007 1:56 PM Subject: Re: SolrSharp example On 6/20/07, Yonik Seeley [EMAIL PROTECTED] wrote: On 6/20/07, Michael Plax [EMAIL PROTECTED] wrote: This is a log that I got after runnning SolrSharp example. I think example program posts not properly formatted xml. I'm running Solr on Windows XP, Java 1.5. Are those settings could be the problem? Solr1.2 is pickier about the Content-type in the HTTP headers. I bet it's being set incorrectly. Ahh, good point. Within SolrSearcher.cs, the WebPost method contains this setting: oRequest.ContentType = application/x-www-form-urlencoded; Looking through the CHANGES.txt file in the 1.2 tagged release on svn: 9. The example solrconfig.xml maps /update to XmlUpdateRequestHandler using the new request dispatcher (SOLR-104). This requires posted content to have a valid contentType: curl -H 'Content-type:text/xml; charset=utf-8'. The response format matches that of /select and returns standard error codes. To enable solr1.1 style /update, do not map /update to any handler in solrconfig.xml (ryan) For SolrSearcher.cs, it sounds as though changing the ContentType setting to text/xml may fix this issue. I don't have a 1.2 instance to test this against available to me right now, but can check this later. Michael, try updating your SolrSearcher.csfile for this content-type setting to see if that resolves your issue. thanks, jeff r.