예제 #1
0
 def test_multi_filters(self):
     s = Search(filter=[
         NF.cnf((Field('Color') == 'Red') & (Field('Color') != 'Blue')),
         NF.dnf(Field('Price').between(0, 100))
     ])
     self.assertEquals(
         s.build(), "products/search?q=" + '&filter=' +
         enc(r"exp=Color:Red,Color:!Blue/type=cnf") + '&filter=' +
         enc(r"exp=Price:[0:100]/type=dnf"))
예제 #2
0
 def test_multi_values(self):
     s = Search(
         filter=NF.cnf(
             (Field('Color') == ('Blue', 'Red')) & \
             (Field('Color') != ('Teal', 'Green'))
         )
     )
     self.assertEquals(
         s.build(), "products/search?q=" + "&filter=" +
         enc(r"exp=Color:Blue|Color:Red,Color:!Teal,Color:!Green/type=cnf"))
예제 #3
0
def read(args):
    company, env, instance = args.instance.split('.')

    engine = Merlin(company,
                    env,
                    instance,
                    host=args.host,
                    use_ssl=args.use_ssl)

    docs = args.docs if not args.inOrder else [[d] for d in args.docs]
    for docSet in docs:
        s = Search(filter=NF.cnf(Field('id') == docSet),
                   fields=args.fields,
                   index=args.index)
        with engine(s) as results:
            for hit in results.hits:
                print(pprint(hit))
예제 #4
0
 def test_lt_gt_facet(self):
     s = Search(q='hoodie',
                filter=NF.cnf((Field('price') < 20) & (Field('age') > 10)))
     self.assertEquals(
         s.build(), "products/search?q=hoodie" + '&filter=' +
         enc(r"exp=price:[:20),age:(10:]/type=cnf"))
예제 #5
0
 def test_single_filter(self):
     s = Search(q='hoodie', filter=NF.cnf(Field('price') <= 20))
     self.assertEquals(
         s.build(), "products/search?q=hoodie" + '&filter=' +
         enc(r"exp=price:[:20]/type=cnf"))
예제 #6
0
# 1.
from merlin import Merlin

engine = Merlin(company='my_company',
                environment='prod',
                instance='my_instance')

# 2.
from merlin.search import Search

with engine(Search(q="dress")) as results:
    print results

# 3. A query where we want 50 results starting from the 100th result
s = Search(q="red dress", start=100, num=50)

with engine(s) as results:
    print results

# 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