Xapian - Search queries retrieve no matches unless '"' is added to each word

139 Views Asked by At

Using C++, I've managed to follow the Xapian tutorial found here.

https://getting-started-with-xapian.readthedocs.io/en/latest/practical_example/index.html#

The indexer program works as I expect it to, but the search program - https://getting-started-with-xapian.readthedocs.io/en/latest/practical_example/searching/building.html - works only with a caveat.

When, for example, I run the equivalent of:

python2 code/python/search1.py db Dent watch

No matches are found, unless I instead write the following:

python2 code/python/search1.py db '"Dent" "watch"'

Which works as well as I expect. The problem is in not quite knowing why it works (though I know the '"' symbol is a search query modifier of some kind), and in how I should aim to prepare queries for processing.

For example, does the Xapian::QueryParser class constructor have an option to add the '"' symbols for me? Or should I preprocess input before I try to retrieve matches?

1

There are 1 best solutions below

0
Charlie On

For the record, using the following queryParser.parse_query(input, queryParser.FLAG_PHRASE) appear to fix the issue I had.