Oh wait, I misunderstood, you want just the highest value _for one
document_, from stored fields, given for each document? StatsComponent
won't help you there.
Either do it client side, or do it at index time in a single stored
field, that's it. Maybe there's some confusing way to use a query
function to do that? But I wouldn't. I'd just do it client side. It's
not an expensive or difficult operation, it's not something that is
solr's specialty.
If you wanted to then use this value in, for existence, relevancy
calculations, THEN you'd have to get solr to do it, and would be in the
realm of trying to use boost functions to do it, which is likely possible.
Jonathan Rochkind wrote:
The stats component will give you the maximum value within one field:
http://wiki.apache.org/solr/StatsComponent
You're going to have to compute the max amongst several fields
client-side, having StatsComponent return the max for each field, and
then just max-ing them client side. Not hard.
Alternately, you could index all of those fields together in one
combined field, and use that combined field with StatsComponent. Leave
them as seperate fields too, but, perhaps using copyField at indexing
time, copy them all to one combined field, which you can then use with
StatsComponent.
Jonathan
Kura wrote:
Hey guys,
Is there a way of doing the following:
We want to get the highest value from a list of multiple fields within a
document.
Example below:
max(field1,field2,field3,field4)
The values are as follow:
field1 = 100
field2 = 300
field3 = 250
field4 = not indexed in document (null)
The highest value is field2 at 300, so we'd want 300 to be what is returned.
Is this at all possible?
Thanks.