سؤال

By default, a multiple word search is split into files that have each word separately. How can I override this default and have whoosh search for an exact match? Even though it's most likely supported, I can't find in google/whoosh documentation.

In addition, would searching for an exact match have better or worse performance than the same multi-word search?

هل كانت مفيدة؟

المحلول

Use phrase queries (that is, put double quotes around the words which you want to be matched in your query), e.g. :

"to be or not to be"

However, this only works if the field you're searching in is of type whoosh.fields.TEXT.

As for the performance thing, phrase searches are necessarily slower than "classic search". To do a phrase search, it is first necessary to retrieve all the documents that contain all the terms that you specified in your query (this is the "classic search" part), and then to compare the terms positions between you query and the document to check if it looks like a match.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top