Exemplo n.º 1
0
 def test_eq3(self):
     where = {"eq": {"a": 1, "b": [2, 3]}}
     result = simplify_esfilter(ES52[jx_expression(
         where)].partial_eval().to_esfilter(identity_schema))
     self.assertEqual(
         result, es_and([{
             "term": {
                 "a": 1
             }
         }, {
             "terms": {
                 "b": [2, 3]
             }
         }]))
Exemplo n.º 2
0
    def test_range_packing2(self):
        where = {
            "and": [{
                "gte": {
                    "build.date": 1429747200
                }
            }, {
                "lt": {
                    "build.date": 1429920000
                }
            }]
        }

        result = simplify_esfilter(ES52[jx_expression(
            where)].partial_eval().to_esfilter(identity_schema))
        self.assertEqual(
            result, {
                "range": {
                    "build.date": {
                        "gte": Date("23 APR 2015").unix,
                        "lt": Date("25 APR 2015").unix
                    }
                }
            })
Exemplo n.º 3
0
 def test_ne2(self):
     where = {"neq": {"a": 1}}
     result = simplify_esfilter(ES52[jx_expression(
         where)].partial_eval().to_esfilter(identity_schema))
     self.assertEqual(result, {"bool": {"must_not": {"term": {"a": 1}}}})
Exemplo n.º 4
0
 def test_eq1(self):
     where = {"eq": {"a": 20}}
     result = simplify_esfilter(ES52[jx_expression(
         where)].partial_eval().to_esfilter(identity_schema))
     self.assertEqual(result, {"term": {"a": 20}})
Exemplo n.º 5
0
    def test_range_packing1(self):
        where = {"and": [{"gt": {"a": 20}}, {"lt": {"a": 40}}]}

        result = simplify_esfilter(ES52[jx_expression(
            where)].partial_eval().to_esfilter(identity_schema))
        self.assertEqual(result, {"range": {"a": {"gt": 20, "lt": 40}}})