Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python advanced search library

I have around 80,000 text files and I want to be able to do an advanced search on them. Let's say I have two lists of keywords and I want to return all the files that include at least one of the keywords in the first list and at least one in the second list. Is there already a library that would do that, I don't want to rewrite it if it exists.

like image 744
Jiyda Moussa Avatar asked Oct 05 '22 13:10

Jiyda Moussa


1 Answers

As you need to search the documents multiple times, you most likely want to index the text files to makes such searches as fast as possible.

Implementing a reasonable index yourself is certainly possible, but a quick search lead me to:

  • https://pypi.python.org/pypi/Whoosh/
  • http://pythonhosted.org/Whoosh/

Take a look at the documentation. It should hopefully be rather trivial to achieve the desired behaviour.

like image 164
nilu Avatar answered Oct 10 '22 01:10

nilu