示例#1
0
 def _update_by_query(index, field_name, old_version, new_version):
     ubq = UpdateByQuery(using=get_connection(), index=index).filter(
         'term', **{
             F'{field_name}__id': old_version.id
         }).script(source=F'ctx._source.{field_name} = params.new_value',
                   params={'new_value': new_version.to_dict()})
     refresh = getattr(settings, 'TEST', False)
     ubq.params(refresh=refresh, conflicts='proceed').execute()
def test_params_being_passed_to_search(mock_client):
    ubq = UpdateByQuery(using="mock")
    ubq = ubq.params(routing="42")
    ubq.execute()

    mock_client.update_by_query.assert_called_once_with(index=None,
                                                        body={},
                                                        routing="42")
def test_params_being_passed_to_search(mock_client):
    ubq = UpdateByQuery(using='mock')
    ubq = ubq.params(routing='42')
    ubq.execute()

    mock_client.update_by_query.assert_called_once_with(
        index=None,
        body={},
        routing='42'
    )