Пример #1
0
 def test(t):
     try:    # Known bug where first request is rejected
         t.status()
     except APIError:
         pass
     t.clear(type='single', timeout=10)
     t.backup('tmp.tar.gz',backup_type='incremental')
     t.insert({1: {'text': 'aste', 'title': 'lol'}, 2: '<item/>'})
     t.insert(['<page><id>3</id><text>foobar</text></page>','<page><id>4</id></page>'], fully_formed=True)
     t.insert({5: '<text>foobar</text>',6: '<text>baz</text>'})
     t.insert([{'page':{'id':7}},{'page':{'id':8}},{'page':{'id':9}}], fully_formed=True)
     t.replace({'page':{'id':3, 'title': 'one'}}, fully_formed=True)
     t.replace({4:{ 'title': 'two'}})
     t.replace({3: {'title': 'one prom'},4: {'title': 'two prim'}})
     t.partial_replace({'page':{'id':5, 'tabs': 'ss'}}, fully_formed=True)
     t.update({4: {'text':'lorem'}})
     t.update({34: {'title':'Far fetched.', 'text': 'Something.'}})
     t.delete([3,1])
     t.search(query.terms_from_dict({'title':'lorem'}))
     t.search_delete({'title':'lorem'})
     t.insert({11: {'title':'test','text':'11-test'}, 12: {'title':'test','text':'12-test'},\
             13: {'title':'test','text':'13-test'},14: {'title':'test','text':'14-test'},\
             15:{'title':'test','text':'15-test'}})
     t.search({'title':'test'}, docs=3, offset=1, list={'text':'yes', 'title': 'no'})
     t.retrieve([11,12])
     t.similar(12, 2, 1, docs=2)
     t.lookup([12,15], list={'title': 'no'})
     t.alternatives(query.term('test'), cr=1, idif=1, h=1)
     t.list_words(query.term('test'))
     t.list_last(docs=1, offset=0)
     t.list_first(list={'text':'yes'}, docs=1, offset=0)
     t.reindex()
     t.status()
Пример #2
0
    def set_query(self, value):
        """ Convert a dict form of query in a string of needed and store the query string.

            Args:
                value -- A query string or a dict with query xpaths as keys and text or
                        nested query dicts as values.
        """
        if isinstance(value, basestring) or value is None:
            self._content['query'] = value
        elif hasattr(value, 'keys'):
            self._content['query'] = query.terms_from_dict(value)
        else:
            raise TypeError("Query must be a string or dict. Got: " + type(value) + " insted!")
Пример #3
0
    def set_query(self, value):
        """ Convert a dict form of query in a string of needed and store the query string.

            Args:
                value -- A query string or a dict with query xpaths as keys and text or
                        nested query dicts as values.
        """
        if isinstance(value, basestring) or value is None:
            self._content['query'] = value
        elif hasattr(value, 'keys'):
            self._content['query'] = query.terms_from_dict(value)
        else:
            raise TypeError("Query must be a string or dict. Got: " +
                            type(value) + " insted!")