Daniel,

This looks like a good usecase for FieldCollapsing (see 
http://wiki.apache.org/solr/FieldCollapsing).  Perhaps try something like:

&group=true&group.field=documentId&group.limit=1&group.sort=version desc

James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311


-----Original Message-----
From: Daniel Skiles [mailto:daniel.ski...@docfinity.com] 
Sent: Wednesday, August 17, 2011 1:20 PM
To: solr-user@lucene.apache.org
Subject: Return records based on aggregate functions?

I've recently started using Solr and I'm stumped by a problem I'm currently
encountering.  Given that I can't really find anything close to what I'm
trying to do on Google or the mailing lists, I figured I'd ask if anyone
here had suggestions on how to do it.

I currently have a schema that looks more or less like this:

uniqueId (string) -- Unique identifier for a record
documentId (string) -- Id of document represented by this record
contents (string) -- contents of file represented by this record
version (float) -- Numeric representation of the version of this document


What I'd like to do is submit a query to the server that returns records
that match against contents, but only if the record has a version field that
is the largest value for all records that share the same documentId.

In other words, I'd like to be able to only search the most recent version
of a document in some scenarios.

Is this possible with Solr?  I'm at an early enough phase that I'm also able
to modify my solr schema if necessary.

Thank you,
Daniel

Reply via email to