문제

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