예제 #1
0
 def index_document(self, document, request=None):
     if engine.is_object_document(document):
         """ Reindex all `document`s. """
         self._bulk('index', document.to_indexable_dict(), request)
     else:
         raise TypeError(
             'Document type must be an instance of a type extending `BaseDocument` not a `{}`'.format(
                 type(document).__name__))
예제 #2
0
 def index(self, documents, request=None, **kwargs):
     if isinstance(documents, list):
         self.index_documents(documents, request=request)
     elif isinstance(documents, set):
         self.index_documents(list(documents), request=request)
     elif engine.is_object_document(documents):
         self._bulk('index', documents.to_indexable_dict(), request)
     else:
         raise TypeError(
             'Documents type must be `list`,`set` or `BaseDocument` not a `{}`'.format(
                 type(documents).__name__))
예제 #3
0
    def index_documents(self, documents, request=None):
        dict_documents = []

        for document in documents:
            if engine.is_object_document(document):
                dict_documents.append(document.to_indexable_dict())
            else:
                raise TypeError("nefertari.elasticsearch.index_documents takes a list of documents extending "
                                "BaseDocument")

        """ Reindex all `document`s. """
        self._bulk('index', dict_documents, request)