Why don't my queries return any results (or the results I expect)?

Generally this means that the terms you are adding when indexing don't match those which your queries are using.

The best way to investigate is to use Query::get_description() (or str(query) in Python) to see what terms you are querying for, then compare these with those which you have indexed by using the delve utility (one of xapian-core's examples). For example, you can see the terms for document 1 using:

xapian-delve -r 1 /path/to/db

See xapian-delve --help or man xapian-delve for full details of how to use xapian-delve. Note that in Xapian 1.2.x and earlier xapian-delve was just called delve (though some packaged versions renamed it to xapian-delve).

If you wrote your own indexing routines for Xapian < 1.0.0, and you're searching with Xapian::QueryParser then your problem is probably due to to the QueryParser in 1.0.0.

In particular, the QueryParser now expects stemmed forms of words to be prefixed with "Z", and both stemmed and unstemmed forms to be present in the database (if you are using stemming). Also, note that you have to turn stemming on in the QueryParser explicitly, by calling QueryParser::set_stem_strategy() with either STEM_SOME or STEM_ALL.

Xapian 1.0.0 has a new TermGenerator class, which generates terms in a manner compatible with the QueryParser class. See for more details of the new term generation strategy.

Another possibility is a bug in the 1.0.0 and 1.0.1 releases which caused the QueryParser to generate incorrect terms when no stemmer was being used (they had a Z prefix, which should only be added to stemmed terms). This would cause searches to find no results (unless indexing was done using a custom term generator). This bug was fixed in 1.0.2.

FAQ Index

Last modified 23 months ago Last modified on 06/03/17 22:40:51