Hello,

short question is this - is there a way for a search to return a field that
is not defined in the schema but is a minimal/maximum value of several
(int/float) fields in solrDocument? (and how would that search look like?)

Longer explanation. I have products and each of them can have a several
prices (price for cash, price for credit cards, coupon price and so on) -
not every product has all the price options. (Don't ask why - that's the use
case:) )

   <field name="priceCash" type="tfloat" indexed="true" stored="true" />
   <field name="priceCreditCard" type="tfloat" indexed="true" stored="true"
/>
   <field name="priceCoupon" type="tfloat" indexed="true" stored="true" />
+2 more

Is there a way to ask "give me the products containing for example 'sony'
and in the results return me the minimal price of all possible prices (for
each product) and SORT the results by that (minimal) price"?

I know I can calculate the minimal price at import/index time and store it
in one separate field but the idea is that users will have checkboxes in
which they could say - i'm only interested in products that have the
priceCreditCard and priceCoupon, show me the smaller of those two and sort
by that value.

My idea is something like this:
?q=sony&minPrice:min(priceCash,priceCreditCard,priceCoupon...)
(the field minPrice is not defined in schema but should return in the
results)

For searching this actually doesn't represent a problem as I can easily
programatically compare the prices and present it to the user. The problem
is sorting - I could do that also programatically but that would mean that
I'd have to pull out all the results query returned (which can be quite big
of course) and then sort them, so that a option I would naturally like to
avoid.

Don't know if I'm asking too much of solr:) but I can see usefulness of
something like this in other examples other then mine. 
Hope the question is clear and if I'm going about things completely the
wrong way please advise in the right direction.
(If there is a similar question asked somewhere else please redirect me - i
didn't find it)

Help much appreciated!

Josip

--
View this message in context: 
http://lucene.472066.n3.nabble.com/Selecting-and-sorting-by-the-min-max-value-from-multiple-fields-tp2841944p2841944.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to