yeraydiazdiaz / lunr.py

A Python implementation of Lunr.js 🌖
http://lunr.readthedocs.io
MIT License
188 stars 16 forks source link

Unable to load index produced from `lunarjs` #102

Closed why-not-try-calmer closed 3 years ago

why-not-try-calmer commented 3 years ago

I must be missing something. I am reading the content of the file attached below fetched over the network using the read() method on aiohttp's Response object. And then:

serialized: Dict[str,Any] = json.loads(raw)
indexes[source]["index"] = Index.load(serialized)

gives me:

cls = <class 'lunr.index.Index'>
serialized_index = {'config': {'indexing': 'full', 'lang': ['en'], 'min_search_length': 3, 'prebuild_index': False, ...}, 'docs': [{'loca...s featuring atomic transactional updates, and distros designed to run container loads.', 'title': 'Pre-install'}, ...]}

    @classmethod
    def load(cls, serialized_index):
        """Load a serialized index"""
        from lunr import __TARGET_JS_VERSION__

        if isinstance(serialized_index, str):
            serialized_index = json.loads(serialized_index)

>       if serialized_index["version"] != __TARGET_JS_VERSION__:
E       KeyError: 'version'

Perhaps it's just late or it's just me. Any clue?

output.txt

why-not-try-calmer commented 3 years ago

Nevermind, I just needed some sleep.