Search code examples
python-3.xinverted-index

how to make inverted index?


how do I update an inverted index efficiently if documents are inserted, deleted or updated ? also should i use index file to store index or should I store index in a database table ?


Solution

  • Python does allow you to constrcut classes that implement dictionary-like interface and thatc ould maintain any inverted indexes you would wish -

    But you are too broad on your question. The "extradict" Python package (pip install extradict), for example have a "BijectiveDict" that just exposes any values as keys and vice-versa, and keep everything synchronize - but it is a simple symmetric key, value store.

    If you want complex, nested documents, and persistence you should use an existing NoSQL database like MongoDB, Codernity, ElasticSearch, ZODB, rather than try to implement one yourself.