[Xapian-discuss] Search for exact match on document

Jorge Cardoso Leitão jorgecarleitao at gmail.com
Mon May 19 14:34:54 BST 2014


Olly,

thank you for your reply and for the suggestion: It is indeed a nice
solution.

Is there a common place with such tips? Maybe it is outside the scope of
Xapian and more
related with "how to index a corpus", but since most Xapian users need to
know both things,
a set of common use cases on indexing could help (e.g. in read the docs).

In any case, thank you for doing Xapian;
I'm the new maintainer of the Xapian backend to Django-Haystack, and I'm
eager to bring it
to the Django community again (the development stalled for 2 years, so it
became unusable and died out).

Cheers,
Jorge



On Mon, May 19, 2014 at 12:02 PM, Olly Betts <olly at survex.com> wrote:

> On Sat, May 17, 2014 at 04:25:06PM +0200, Jorge Cardoso Leitão wrote:
> > More generally, the question can be posed on the following terms: how
> can I
> > query exact matches to fields?
>
> I'd suggest indexing special terms to mark the start and end of fields
> for which you want to do exact matching, such that the start term's
> position is one before the first real position in that field, and the
> end term's position is one after the last real position.
>
> If you make these terms FNAME^ and FNAME$, then you can build a suitable
> phrase query in Python like so:
>
>      terms = ['FNAME^', 'FNAMEfoo', 'FNAMEbar', 'FNAME$']
>      xapian.Query(xapian.Query.OP_PHRASE, terms)
>
> You can also use these special terms to anchor a match to just the start
> or just the end of a field.
>
> Cheers,
>     Olly
>


More information about the Xapian-discuss mailing list