You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by dm_tim <dm...@yahoo.com> on 2012/11/09 21:02:34 UTC

4.0 query question

Howdy,

I have a Solr query that is almost perfect:
http://localhost:8080/apache-solr-4.0.0/v3_tag_core/select?q=tag%3A%22coat%22%5E4+%22coat%22+cid%3A136+&sort=score+desc&rows=10&fl=id+tag+cid+file_version+lang+score&wt=json&indent=true&debugQuery=true

It's grabbing data that includes the fields: id, tag, cid, file_version,
lang, and score AND sorting them by score descending. Excellent! However, I
need to figure out how to have the query only return rows with the same cid
that have the highest file_version. For example if it finds two rows with
the same cid and one has file_version 14 and another with file version 10,
it should toss out the one with file version 10. Note that there may be
multiple rows with the same file_version and I'd like all of them with the
highest file_version.

I just can't find an explanation for this in the docs. Any help would be
appreciated.

Regards,

Tim





--
View this message in context: http://lucene.472066.n3.nabble.com/4-0-query-question-tp4019397.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: 4.0 query question

Posted by dm_tim <dm...@yahoo.com>.
That is terrific. Thanks.

Regards,

Tim



--
View this message in context: http://lucene.472066.n3.nabble.com/4-0-query-question-tp4019397p4019890.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: 4.0 query question

Posted by Amit Nithian <an...@gmail.com>.
Why not group by cid using the grouping component, within the group sort by
version descending and return 1 result per group.

http://wiki.apache.org/solr/FieldCollapsing

Cheers
Amit


On Fri, Nov 9, 2012 at 2:56 PM, dm_tim <dm...@yahoo.com> wrote:

> I think I may have found my answer buy I'd like additional validation:
> I believe that I can add a function to my query to get only the highest
> values of 'file_version' like this -
> _val_:"max(file_version, 1)"
>
> I seem to be getting the results I want. Does this look correct?
>
> Regards,
>
> Tim
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/4-0-query-question-tp4019397p4019426.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: 4.0 query question

Posted by dm_tim <dm...@yahoo.com>.
I think I may have found my answer buy I'd like additional validation:
I believe that I can add a function to my query to get only the highest
values of 'file_version' like this -
_val_:"max(file_version, 1)"

I seem to be getting the results I want. Does this look correct?

Regards,

Tim



--
View this message in context: http://lucene.472066.n3.nabble.com/4-0-query-question-tp4019397p4019426.html
Sent from the Solr - User mailing list archive at Nabble.com.