Exact match of multiple words in whoosh

筅森魡賤 提交于 2019-12-02 03:14:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17284758/exact-match-of-multiple-words-in-whoosh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!