> Is there a way to require a portion of a query only if there are values
for
> > > that field in the document?
> > > e.g. If I know that I only want to match movies made between 1973 and
> > > 1975,
> > > I would like to be able to say in my query that if the document has a
> > > year,
> > > it must be in that range, but if the document has no year at all,
don't
> > > fail
> > > the document for that reason alone.
> > > This is also important in the director name part.  If a document has
a
> > > director given, and it doesn't match what I'm searching for, that
should
> > > be
> > > a fail, but if the document has no director field, I don't want to
fail
> > > the
> > > document for that reason alone.
> >
> >
> > You'll have to include a dummy value I think. Remember that you're
> > searching for stuff with Lucene, so saying "match even if there's
> > nothing there" is, er, ABnormal..
> >
> > I'd think about putting a dummy value in those fields you want to
handle
> > this way. For instance, add "matchall" to documents with no date. Then
> > you'd need to add an 'or date:matchall' clause to all the dates you
query
> > on. Make sure it's a value that behaves reasonably when you want to
> > include all dates, or all dates before ####, or all dates after ####.
> >
>
> Hrm.  I'll keep this idea on the cheat sheet for now. It turns out that

Just to note that in case you do want this, then while
it would be more efficient to index a matchall word (as
Erik suggested), in case it was too late for this (index
already exists, etc.), it is still possible to phrase a
query that applies a range filter only upon docs containing
the range filter field.

With a query parser set to allowLeadingWildcard, this should do:

( +item -price:* ) ( +item +price:[0100 TO 0150] )

or, to avoid too-many-cluases risk:

( +item -price:[MIN TO MAX]) ( +item +price:[0100 TO 0150] )

where MIN and MAX cover (at least) the full range of the ranged field.

Doron


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to