How about this -
Lets say your domain objects had these three things you care about - P1, D
and P2 (P1 is the price valid before D and P2 after this date).
Index each such document twice (Please don't kill me for suggesting this).
There are two fields which you should index with the document - epoch and
price. One document has a value D in the epoch field and price P1. The other
document would have a value (D+1) in the epoch field and P2 in the price
field.

I am assuming, that all your queries to this index have a filterQuery
appended to it, always. So for any given date that you want to query on, you
can add a filter query (epoch lt incomingDate) to your query. This will make
sure you always get just one document of the two that has been indexed.

Other than doubling your index size, is there something fundamentally wrong
with this design?
More importantly, does this work?

Cheers
Avlesh

On Thu, May 7, 2009 at 6:15 AM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> On Wed, May 6, 2009 at 7:32 AM, Andrew Ingram <a...@andrewingram.net>
> wrote:
> > Basically, a product has two price values and a date, the product
> > effectively has one price before the date and the other one after.
> > This poses no problem for the site itself since I can use conditional
> > logic, but I have no idea how to approach this with regards to solr
> > queries.
> >
> > The price of a product is used for both faceting and sorting and
> > should use whichever price is active at the time of the query. Is
> > there any way to do define a field whose value is a simple algorithm
> > operating on the value of other fields?
>
> Sort of - function queries.
>
> We don't have any conditional function queries yet, but that's easy.
> You can't yet sort by a function query, but we should fix that.
> You can't yet facet on a function query, but we should fix that too.
>
> Short term, Erick's index the doc twice idea may be best.
> Long term, out-of-the-box functionality after volunteers help develop
> out the function query approach :-)
>
> -Yonik
> http://www.lucidimagination.com
>

Reply via email to