Exemple #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")
    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")
Exemple #3
0
    def delete(self, id):
        """
        Remove document that matches id from index.
        """

        indexer = Indexer()
        indexer.remove_doc(unicode(id))
        self.set_status(204)
        self.write("index deletion succeeds")
    def delete(self, id):
        """
        Remove document that matches id from index.
        """

        indexer = Indexer()
        indexer.remove_doc(unicode(id))
        self.set_status(204)
        self.write("index deletion succeeds")
    def post(self):
        '''
        Perform search query.
        '''
        self.load_json()
        query = self.get_field('query')
        docType = self.get_field('docType')

        indexer = Indexer()
        result = indexer.search_doc(query, docType)
        self.write(json_encode({ 'ids': result }))
Exemple #6
0
    def post(self):
        '''
        Perform search query.
        '''
        self.load_json()
        query = self.get_field('query')
        docTypes = self.get_field('docType', [])

        # For backward compatibility, it accepts a single string
        # but turn it into an array
        if isinstance(docTypes, basestring):
            docTypes = [docTypes]

        numPage = int(self.get_field('numPage', 1))
        numByPage = int(self.get_field('numByPage', 10))
        showNumResults = self.get_field('showNumResults', False)

        indexer = Indexer()
        result = indexer.search_doc(query, docTypes, numPage, numByPage,
                                    showNumResults)
        self.write(json_encode(result))
    def post(self):
        '''
        Perform search query.
        '''
        self.load_json()
        query = self.get_field('query')
        docTypes = self.get_field('docType', [])

        # For backward compatibility, it accepts a single string
        # but turn it into an array
        if isinstance(docTypes, basestring):
            docTypes = [docTypes]

        numPage = int(self.get_field('numPage', 1))
        numByPage = int(self.get_field('numByPage', 10))
        showNumResults = self.get_field('showNumResults', False)

        indexer = Indexer()
        result = indexer.search_doc(query, docTypes, numPage, numByPage,
                                    showNumResults)
        self.write(json_encode(result))
Exemple #8
0
 def delete(self):
     indexer = Indexer()
     indexer.remove_all()
     self.write('deletion succeeds')
Exemple #9
0
def and_i_index_them(step):
    world.indexer = Indexer()
    for note in world.notes:
        world.indexer.index_doc("Note", note, ["title", "content"], {})
Exemple #10
0
 def delete(self):
     indexer = Indexer()
     indexer.remove_all()
     self.write('deletion succeeds')