예제 #1
0
 def test_sort_order_serialization_with_nested_path(self):
     sort_order = SortOrder('foo', mode='avg', nested_path='bar')
     self.assertEqual(sort_order.serialize(),
                      {'foo': {
                          'nested_path': 'bar',
                          'mode': 'avg'
                      }})
예제 #2
0
 def test_sorting_by_foo(self):
     search = Search(MatchAllQuery())
     search.sort.add(SortOrder('foo', order='desc'))
     resultset = self.conn.search(search,
                                  indices=self.index_name,
                                  doc_types=[self.document_type])
     ids = [doc['_id'] for doc in resultset.hits]
     self.assertEqual(ids, ['3', '2', '1'])
예제 #3
0
파일: es_util.py 프로젝트: niyoufa/ods
def search_add_sort(query, sort_field, sort_type):
    search = Search(query)
    sort_order = SortOrder(sort_field, sort_type)
    search.sort.add(sort_order)
    return search
예제 #4
0
파일: test_sort.py 프로젝트: 0x64746b/pyes
 def test_sort_order_serialization_with_nested_path(self):
     sort_order = SortOrder('foo', mode='avg', nested_path='bar')
     self.assertEqual(
         sort_order.serialize(),
         {'foo': {'nested_path': 'bar', 'mode': 'avg'}}
     )
예제 #5
0
파일: test_sort.py 프로젝트: 0x64746b/pyes
 def test_sort_order_serialization_with_missing(self):
     sort_order = SortOrder('foo', missing='_last')
     self.assertEqual(sort_order.serialize(), {'foo': {'missing': '_last'}})
예제 #6
0
파일: test_sort.py 프로젝트: 0x64746b/pyes
 def test_sort_order_serialization_with_order(self):
     sort_order = SortOrder('foo', 'asc')
     self.assertEqual(sort_order.serialize(), {'foo': {'order': 'asc'}})
예제 #7
0
파일: test_sort.py 프로젝트: 0x64746b/pyes
 def test_sort_order_serialization(self):
     sort_order = SortOrder('foo')
     self.assertEqual(sort_order.serialize(), {'foo': {}})
예제 #8
0
 def test_sort_order_serialization_with_missing(self):
     sort_order = SortOrder('foo', missing='_last')
     self.assertEqual(sort_order.serialize(), {'foo': {'missing': '_last'}})
예제 #9
0
 def test_sort_order_serialization_with_order(self):
     sort_order = SortOrder('foo', 'asc')
     self.assertEqual(sort_order.serialize(), {'foo': {'order': 'asc'}})
예제 #10
0
 def test_sort_order_serialization(self):
     sort_order = SortOrder('foo')
     self.assertEqual(sort_order.serialize(), {'foo': {}})
예제 #11
0
 def test_sort_factory_reset(self):
     sort_factory = SortFactory()
     sort_factory.add(SortOrder('foo'))
     self.assertEqual(len(sort_factory.sort_orders), 1)
     sort_factory.reset()
     self.assertEqual(len(sort_factory.sort_orders), 0)
예제 #12
0
 def test_sort_factory_with_sort_order(self):
     sort_factory = SortFactory()
     sort_factory.add(SortOrder('foo'))
     self.assertEqual(sort_factory.serialize(), [{'foo': {}}])