lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Meredith <andymered...@gmail.com>
Subject Re: Filtering a query by range returning unexpected results
Date Mon, 02 Jul 2012 17:53:15 GMT
Yep, that 15.00.00 was a typo.

Here are the relevant portions of my schema.xml:

<types>
    <!-- CUT -->
    <fieldType name="currency" class="solr.CurrencyField" precisionStep="8"
defaultCurrency="USD" currencyConfig="currency.xml" />
    <!-- CUT -->
</types>

<fields>
    <!-- CUT -->
    <field name="prices" type="currency" indexed="true" stored="true"
multiValued="true" />
    <!-- CUT -->
</fields>

And here is the output of a sample query with &debugQuery=on appended:

<lst name="debug">
<str name="rawquerystring">Furtick</str>
<str name="querystring">Furtick</str>
<str name="parsedquery">
+DisjunctionMaxQuery((subtitle:furtick | frontlist_flapcopy:furtick^0.5 |
frontlist_ean:furtick^6.0 | author:furtick^3.0 | series:furtick^1.5 |
title:furtick^2.0)) ()
</str>
<str name="parsedquery_toString">
+(subtitle:furtick | frontlist_flapcopy:furtick^0.5 |
frontlist_ean:furtick^6.0 | author:furtick^3.0 | series:furtick^1.5 |
title:furtick^2.0) ()
</str>
<lst name="explain"/>
<str name="QParser">ExtendedDismaxQParser</str>
<null name="altquerystring"/>
<null name="boostfuncs"/>
<arr name="filter_queries">
<str>prices:[5.00 TO 21.00]</str>
<str>forsaleinusa:true</str>
</arr>
<arr name="parsed_filter_queries">
<str>
ConstantScore(frange(currency(prices)):[500 TO 2100])
</str>
<str>forsaleinusa:true</str>
</arr>
<lst name="timing">
<double name="time">3.0</double>
<lst name="prepare">
<double name="time">2.0</double>
<lst name="org.apache.solr.handler.component.QueryComponent">
<double name="time">2.0</double>
</lst>
<lst name="org.apache.solr.handler.component.FacetComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.HighlightComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.StatsComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.SpellCheckComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.DebugComponent">
<double name="time">0.0</double>
</lst>
</lst>
<lst name="process">
<double name="time">1.0</double>
<lst name="org.apache.solr.handler.component.QueryComponent">
<double name="time">1.0</double>
</lst>
<lst name="org.apache.solr.handler.component.FacetComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.HighlightComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.StatsComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.SpellCheckComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.DebugComponent">
<double name="time">0.0</double>
</lst>
</lst>
</lst>
</lst>


If I run this same query with the filter, prices:[5.00 TO 99.00], then I
get a result that includes the following field:

<arr name="prices">
<str>12.99,USD</str>
<str>14.99,USD</str>
<str>15.00,USD</str>
<str>25.00,USD</str>
</arr>


I can't figure out why this is not being returned with the first query.
I'll try re-building the index with the "prices" field type set to float
and see if that changes the behaviour.

On Sat, Jun 30, 2012 at 6:49 PM, Erick Erickson <erickerickson@gmail.com>wrote:

> This works fine for me with 3.6, float fields and even on a currency type.
>
> I'm assuming a typo for 15.00.00 BTW.
>
> I admit I'm not all that familiar with the "currency" type, which I infer
> you're
> using given the "USD" bits. But I ran a quick test with currency types and
> it worked at least the way I ran it... But another quick look shows that
> some interesting things are being done with the "currency" type, so who
> knows?
>
> So, let's see your relevant schema bits, and the results of your query
> when you attach &debugQuery=on to it.....
>
>
> Best
> Erick
>
> On Fri, Jun 29, 2012 at 2:43 PM, Andrew Meredith <andymeredith@gmail.com>
> wrote:
> > First off, I have to say that I am working on my first project that has
> > required me to work with Solr, so my question my be very elementary - I
> > just could not find an answer elsewhere.
> >
> > I am trying to add a ranged query filter that returns all items in a
> given
> > "prices" range. In my situation, each item can have multiple prices, so
> it
> > is a multivalued field. When I search a range, say, prices:[15.00.00 TO
> > 21.00], I want Solr to return all items that have *any* price in that
> > range, rather than returning results where *all* prices are in the range.
> > For example, if i have an item with the following prices, it will not be
> > returned:
> >   <arr name="prices">
> >   <str>19.99,USD</str>
> >   <str>22.50,USD</str>
> >   </arr>
> >
> > Is there any way to change the behaviour of Solr so that it will match
> > documents in which any value of a multivalued field matches a ranged
> query
> > filter?
> >
> > Thanks!
> >
> > --
> > <http://ofchristonearth.wordpress.com/>
> > S.D.G.
>



-- 
Andrew Meredith

Personal Blog: Soli Deo Gloria <http://kendru.wordpress.com/>
Programming Blog <http://www.andrewmeredith.info>

S.D.G.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message