コード例 #1
0
def test_reverse():
    d = {
        "query": {
            "filtered": {
                "filter": {
                    "bool": {
                        "should": [
                            {"term": {"category": "meetup"}},
                            {"term": {"category": "conference"}},
                        ]
                    }
                },
                "query": {
                    "bool": {
                        "must": [{"match": {"title": "python"}}],
                        "must_not": [{"match": {"title": "ruby"}}],
                        "minimum_should_match": 2,
                    }
                },
            }
        },
        "script": {
            "source": "ctx._source.likes += params.f",
            "lang": "painless",
            "params": {"f": 3},
        },
    }

    d2 = deepcopy(d)

    ubq = UpdateByQuery.from_dict(d)

    assert d == d2
    assert d == ubq.to_dict()
コード例 #2
0
def test_reverse():
    d = {
        'query': {
            'filtered': {
                'filter': {
                    'bool': {
                        'should': [{
                            'term': {
                                'category': 'meetup'
                            }
                        }, {
                            'term': {
                                'category': 'conference'
                            }
                        }]
                    }
                },
                'query': {
                    'bool': {
                        'must': [{
                            'match': {
                                'title': 'python'
                            }
                        }],
                        'must_not': [{
                            'match': {
                                'title': 'ruby'
                            }
                        }],
                        'minimum_should_match': 2
                    }
                }
            }
        },
        'script': {
            'source': 'ctx._source.likes += params.f',
            'lang': 'painless',
            'params': {
                'f': 3
            }
        }
    }

    d2 = deepcopy(d)

    ubq = UpdateByQuery.from_dict(d)

    assert d == d2
    assert d == ubq.to_dict()
コード例 #3
0
def test_reverse():
    d =  {
        'query': {
            'filtered': {
                'filter': {
                    'bool': {
                        'should': [
                            {'term': {'category': 'meetup'}},
                            {'term': {'category': 'conference'}}
                        ]
                    }
                },
                'query': {
                    'bool': {
                        'must': [ {'match': {'title': 'python'}}],
                        'must_not': [{'match': {'title': 'ruby'}}],
                        'minimum_should_match': 2
                    }
                }
            }
        },
        'script': {
            'source': 'ctx._source.likes += params.f',
            'lang': 'painless',
            'params': {
                'f': 3
            }
        }
    }

    d2 = deepcopy(d)

    ubq = UpdateByQuery.from_dict(d)

    assert d == d2
    assert d == ubq.to_dict()
コード例 #4
0
def test_from_dict_doesnt_need_query():
    ubq = UpdateByQuery.from_dict({'script': {'source': 'test'}})

    assert {
        'script': {'source': 'test'}
    } == ubq.to_dict()
コード例 #5
0
def test_from_dict_doesnt_need_query():
    ubq = UpdateByQuery.from_dict({'script': {'source': 'test'}})

    assert {'script': {'source': 'test'}} == ubq.to_dict()
コード例 #6
0
def test_from_dict_doesnt_need_query():
    ubq = UpdateByQuery.from_dict({"script": {"source": "test"}})

    assert {"script": {"source": "test"}} == ubq.to_dict()