OK, this appears to be something with the "currency" type. It works fine for
regular float fields. I can't get the multiValued currency types to work with
range queries. Don't quite know what I was doing when I thought they
_did_ work.

One work-around I think, if you are using a single currency USD might be
to copy your price to a simple float field and do your range queries on that.

I'm not at all sure that the currency type was ever intended to support
multiValued="true". I don't know enough about the internals to know if
it's even a good idea to try, but the current behavior could be improved
upon.

But it seems to me that one of two things should happen:
1> the startup should barf if a currency type is multiValued (fail early)
or
2> currency should work when multiValued.

Unfortunately, JIRA is down so I can't look to see if this is already a known
issue or enter a JIRA if it isn't. I'll try to look later if it all
comes back up.

Best
Erick

On Mon, Jul 2, 2012 at 1:53 PM, Andrew Meredith <andymered...@gmail.com> wrote:
> 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 
> <erickerick...@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 <andymered...@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.

Reply via email to