def put(self, documents):
        """Add `documents` to this index"""

        def get_fields(d):
            """Convenience function for getting the search API fields list
            from the given document `d`.
            """
            field = lambda f, n, v: self.FIELD_MAP[type(f)](name=n, value=v)
            return [
                field(f, n, f.to_search_value(getattr(d, n, None)))
                for n, f in d._meta.fields.items()
            ]

        # If documents is actually just a single document, stick it in a list
        try:
            len(documents)
        except __HOLE__:
            documents = [documents]

        # Construct the actual search API documents to add to the underlying
        # search API index
        search_docs = [
            search_api.Document(
                doc_id=d.doc_id,
                rank=d._rank,
                fields=get_fields(d)
            )
            for d in documents
        ]
        return self._index.put(search_docs)
dataset/ETHPy150Open potatolondon/search/search/indexes.py/Index.put