On Jun 19, 2010, at 7:48pm, Erik Hatcher wrote:
That's not a bug with the example schema, as price is a single-
valued field. getFirstValue will work, yes, but isn't necessary
when it's single valued. If you've got multiple prices, you
probably want something like:
#foreach($price in $doc.getFieldValue('price'))$!
number.currency($price)#end
Note that in your scenario it isn't returning a string with brackets
(except to the UI) - it's truly an array within the template.
Though maybe what you want in your schema is a single valued price
field? :)
I must be missing something...
Here's what's in my schema:
<field name="price" type="float" indexed="true" stored="true"/>
Which is exactly what was in the original example schema.
I can't look at the index using the latest Luke - I'd need to rebuild
Luke with the current Lucene code, since the format is now version 10.
I tried using solr/admin/analysis, to see what a query is returning,
but I get a server error (500):
=
=
=
=
=
=
=
========================================================================
HTTP ERROR 500
Problem accessing /solr/admin/analysis.jsp. Reason:
java.lang.IllegalArgumentException: NumericTokenStream does not
support CharTermAttribute.
org.apache.jasper.JasperException: java.lang.IllegalArgumentException:
NumericTokenStream does not support CharTermAttribute.
at
org
.apache
.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:418)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
511)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
at
org
.apache
.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:263)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at
org
.mortbay
.jetty
.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
230)
at
org
.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector
$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.IllegalArgumentException: NumericTokenStream does
not support CharTermAttribute.
at org.apache.lucene.analysis.NumericTokenStream
$
NumericAttributeFactory
.createAttributeInstance(NumericTokenStream.java:125)
at
org
.apache.lucene.util.AttributeSource.addAttribute(AttributeSource.java:
245)
at
org
.apache
.jsp.admin.analysis_jsp.getTokens(org.apache.jsp.admin.analysis_jsp:136)
at
org
.apache
.jsp.admin.analysis_jsp._jspService(org.apache.jsp.admin.analysis_jsp:
721)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
org
.apache
.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
... 29 more
=
=
=
=
=
=
=
========================================================================
Looks like it's not happy doing analysis on a TrieFloatField.
When I do searches against the index using solr/admin, the results
only have a single value, e.g.:
<result name="response" numFound="4" start="0" maxScore="4.880418">
<doc>
<float name="score">4.880418</float>
<arr name="product_id">
<str>27126</str>
</arr>
<arr name="price">
<float>2.29</float>
</arr>
<arr name="product_name">
<str>KAS Rugs Indira Black Circles Rug</str>
</arr>
...
</doc>
</result>
Any other ideas what might be going on?
Thanks,
-- Ken
On Jun 19, 2010, at 9:12 PM, Ken Krugler wrote:
I noticed that my prices weren't showing up, even though I've got a
price field.
I think the issue is with this line from hit.vm:
<p><b>#field('name')</b> $!
number.currency($doc.getFieldValue('price'))</p>
The number.currency() function needs to get passed something that
looks like a number, but $doc.getFieldValue() will return "[2.96]",
because it could be a list of values.
The square brackets confuse number.currency, so you get no price.
I think this line needs to be:
<p><b>#field('name')</b> $!
number.currency($doc.getFirstValue('price'))</p>
...since getFirstValue() returns a single value without brackets.
-- Ken
--------------------------------------------
<http://ken-blog.krugler.org>
+1 530-265-2225
--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c w e b m i n i n g