Jeff,

Thanks! Your suggestion worked, instead of invoking ToString() on
float values I've used ToString's other signature, which takes a an
IFormatProvider:

CultureInfo MyCulture = CultureInfo.InvariantCulture;
this.Add(new IndexFieldValue("weight",
weight.ToString(MyCulture.NumberFormat)));
this.Add(new IndexFieldValue("price", price.ToString(MyCulture.NumberFormat)));

This made me think on a related issue though. In this case it was the
client that was using a non-invariant number format, but can this also
happen on Solr's side? If so, I guess I may need to configure it
somewhere...

Cheers,
Filipe Correia

On 10/10/07, Jeff Rodenburg <[EMAIL PROTECTED]> wrote:
> Hi Felipe -
>
> The issue you're encountering is a problem with the data format being passed
> to the solr server.  If you follow the stack trace that you posted, you'll
> notice that the solr field is looking for a value that's a float, but the
> passed value is "1,234".
>
> I'm guessing this is caused by one of two possibilities:
>
> (1) there's a typo in your example code, where "1,234" should actually be "
> 1.234", or
> (2) there's a culture settings difference on your server that's converting "
> 1.234" to "1,234"
>
> Assuming it's the latter, add this line in the ExampleIndexDocument
> constructor:
>
> CultureInfo MyCulture = new CultureInfo("en-US");
>
> Please let me know if this fixes the issue, I've been looking at this
> previously and would like to confirm it.
>
> thanks,
> jeff r.
>
>
> On 10/10/07, Filipe Correia <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I am trying to run SolrSharp's example application but am getting a
> > WebException with a ServerProtocolViolation status message.
> >
> > After some debugging I found out this is happening with a call to:
> > http://localhost:8080/solr/update/
> >
> > And using fiddler[1] found out that solr is actually throwing the
> > following exception:
> > org.apache.solr.core.SolrException: Error while creating field
> > 'weight{type=sfloat,properties=indexed,stored,omitNorms,sortMissingLast}'
> > from value '1,234'
> >         at org.apache.solr.schema.FieldType.createField(FieldType.java
> > :173)
> >         at org.apache.solr.schema.SchemaField.createField(SchemaField.java
> > :94)
> >         at org.apache.solr.update.DocumentBuilder.addSingleField(
> > DocumentBuilder.java:57)
> >         at org.apache.solr.update.DocumentBuilder.addField(
> > DocumentBuilder.java:73)
> >         at org.apache.solr.update.DocumentBuilder.addField(
> > DocumentBuilder.java:83)
> >         at org.apache.solr.update.DocumentBuilder.addField(
> > DocumentBuilder.java:77)
> >         at org.apache.solr.handler.XmlUpdateRequestHandler.readDoc(
> > XmlUpdateRequestHandler.java:339)
> >         at org.apache.solr.handler.XmlUpdateRequestHandler.update(
> > XmlUpdateRequestHandler.java:162)
> >         at
> > org.apache.solr.handler.XmlUpdateRequestHandler.handleRequestBody(
> > XmlUpdateRequestHandler.java:84)
> >         at org.apache.solr.handler.RequestHandlerBase.handleRequest(
> > RequestHandlerBase.java:77)
> >         at org.apache.solr.core.SolrCore.execute(SolrCore.java:658)
> >         at org.apache.solr.servlet.SolrDispatchFilter.execute(
> > SolrDispatchFilter.java:191)
> >         at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
> > SolrDispatchFilter.java:159)
> >         at
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:235)
> >         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:206)
> >         at org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:233)
> >         at org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:175)
> >         at org.apache.catalina.core.StandardHostValve.invoke(
> > StandardHostValve.java:128)
> >         at org.apache.catalina.valves.ErrorReportValve.invoke(
> > ErrorReportValve.java:102)
> >         at org.apache.catalina.core.StandardEngineValve.invoke(
> > StandardEngineValve.java:109)
> >         at org.apache.catalina.connector.CoyoteAdapter.service(
> > CoyoteAdapter.java:263)
> >         at org.apache.coyote.http11.Http11Processor.process(
> > Http11Processor.java:844)
> >         at
> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
> > Http11Protocol.java:584)
> >         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
> > JIoEndpoint.java:447)
> >         at java.lang.Thread.run(Unknown Source)
> > Caused by: java.lang.NumberFormatException: For input string:
> > &quot;1,234&quot;
> >         at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
> >         at java.lang.Float.parseFloat(Unknown Source)
> >         at org.apache.solr.util.NumberUtils.float2sortableStr(
> > NumberUtils.java:80)
> >         at org.apache.solr.schema.SortableFloatField.toInternal(
> > SortableFloatField.java:50)
> >         at org.apache.solr.schema.FieldType.createField(FieldType.java
> > :171)
> >         ... 24 more
> > type Status report
> > message Error while creating field
> > 'weight{type=sfloat,properties=indexed,stored,omitNorms,sortMissingLast}'
> > from value '1,234'
> >
> > I am just starting to try Solr, and might be missing some
> > configurations, but I have no clue where to begin to investigate this
> > further without digging into Solr's source, which I would really like
> > to avoid for now. Any thoughts?
> >
> > thank you in advance,
> > Filipe Correia
> >
> > [1] http://www.fiddlertool.com/
> >
>

Reply via email to