def test_sorting(self): s = Search( q = "pants", sort = [ S.desc('brand'), S.asc('price') ] ) self.assertEquals(s.build(), "products/search?q=pants" + '&sort=' + enc("brand:desc,price:asc") )
def test_group(self): s = Search(q='hoodie', group=Group(field='category', num=10, sort=S.asc('price'))) self.assertEquals( s.build(), "products/search?q=hoodie" + '&group=' + enc(r"field=category/sort=price:asc/num=10"))
def test_sort(self): s = Search(q='', sort = S.asc('price'), fields= ['price'] ) with self.engine(s) as r: self.assertEquals(r.hits.numFound, 5) self.assertEquals(r.hits[0]['price'], '59.0 USD') self.assertEquals(r.hits[-1]['price'], '178.0 USD')
def test_group(self): s = Search( q='hoodie', group=Group(field='category', num=10, sort=S.asc('price')) ) self.assertEquals(s.build(), "products/search?q=hoodie" + '&group=' + enc(r"field=category/sort=price:asc/num=10") )
# 4. A query where we only want back the "id" and "title" fields s = Search(q="red dress", fields=["id", "title"]) with engine(s) as results: print results # 5. Get all fields including debug fields s = Search(q='red dress', fields=['[debug]']) with engine(s) as results: print results # 6. from merlin.sort import Sort as S s = Search(q='red dress', sort=S.asc('price')) with engine(s) as results: print results # 7. s = Search(q='red dress', sort = [S.asc('price'), S.desc('size')]) with engine(s) as results: print results # 8. from merlin.filter import NF, Field s = Search( q = 'red dress', filter = NF.cnf(
def test_sorting(self): s = Search(q="pants", sort=[S.desc('brand'), S.asc('price')]) self.assertEquals( s.build(), "products/search?q=pants" + '&sort=' + enc("brand:desc,price:asc"))
def test_sort(self): s = Search(q='', sort=S.asc('price'), fields=['price']) with self.engine(s) as r: self.assertEquals(r.hits.numFound, 5) self.assertEquals(r.hits[0]['price'], '59.0 USD') self.assertEquals(r.hits[-1]['price'], '178.0 USD')
# 4. A query where we only want back the "id" and "title" fields s = Search(q="red dress", fields=["id", "title"]) with engine(s) as results: print results # 5. Get all fields including debug fields s = Search(q='red dress', fields=['[debug]']) with engine(s) as results: print results # 6. from merlin.sort import Sort as S s = Search(q='red dress', sort=S.asc('price')) with engine(s) as results: print results # 7. s = Search(q='red dress', sort=[S.asc('price'), S.desc('size')]) with engine(s) as results: print results # 8. from merlin.filter import NF, Field s = Search(q='red dress', filter=NF.cnf(Field('price') < 100))