Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 4
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")
Ejemplo n.º 5
0
    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 }))
Ejemplo n.º 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))
Ejemplo n.º 7
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))
Ejemplo n.º 8
0
 def delete(self):
     indexer = Indexer()
     indexer.remove_all()
     self.write('deletion succeeds')
Ejemplo n.º 9
0
def and_i_index_them(step):
    world.indexer = Indexer()
    for note in world.notes:
        world.indexer.index_doc("Note", note, ["title", "content"], {})
Ejemplo n.º 10
0
 def delete(self):
     indexer = Indexer()
     indexer.remove_all()
     self.write('deletion succeeds')