Beispiel #1
0
    def post(self):
        '''
        Add given document to index.
        '''

        self.load_json()
        doc = self.get_field("doc")
        fields = self.get_field("fields")
        fieldsType = self.get_field('fieldsType', {})

        if "id" not in doc:
            id = doc.get("_id", None)
            if id is None:
                self.raise_argument_error("doc.id")
            else:
                doc["id"] = id
        if "tags" not in doc:
            doc["tags"] = []

        docType = doc.get("docType", None)
        if docType is None:
            self.raise_argument_error("doc.docType")
        if not len(fields):
            self.raise_argument_error("fields")
        else:
            indexer = Indexer()
            indexer.index_doc(docType, doc, fields, fieldsType)
            self.write("indexation succeeds")
Beispiel #2
0
    def post(self):
        '''
        Add given document to index.
        '''

        self.load_json()
        doc = self.get_field("doc")
        fields = self.get_field("fields")
        fieldsType = self.get_field('fieldsType', {})

        if not "id" in doc:
            id = doc.get("_id", None)
            if id is None:
                self.raise_argument_error("doc.id")
            else:
                doc["id"] = id
        if not "tags" in doc:
            doc["tags"] = []

        docType = doc.get("docType", None)
        if docType is None:
            self.raise_argument_error("doc.docType")
        if not len(fields):
            self.raise_argument_error("fields")
        else:
            indexer = Indexer()
            indexer.index_doc(docType, doc, fields, fieldsType)
            self.write("indexation succeeds")