def test_filters_are_applied_to_search_ant_relevant_facets():
    bs = BlogSearch('python search', filters={'category': 'elastic', 'tags': ['python', 'django']})
    s = bs.build_search()

    d = s.to_dict()


    # we need to test post_filter without relying on order
    f = d['post_filter']['bool'].pop('must')
    assert len(f) == 2
    assert f in {'terms': {'category.raw': ['elastic']}}
    assert {'terms': {'tags': ['python', 'django']}} in f

    assert {
        'aggs': {
            '_filter_tags': {
                'filter': {
                    'terms': {'category.raw': ['elastic']},
                },
                'aggs': {'tags': {'terms': {'field': 'tags'}}},
            },
            '_filter_category': {
                'filter': {
                    'terms': {'tags': ['python', 'django']},
                },
                'aggs': {'category': {'terms': {'field': 'category.raw'}}},
            }
        },
        'query': {
            'multi_match': {'fields': ('title', 'body'), 'query': 'python search'}
        },
        'post_filter': {
            'bool': {
            }
        },
        'highlight': {'fields': {'body': {}, 'title': {}}}
    } == d
dataset/ETHPy150Open elastic/elasticsearch-dsl-py/test_elasticsearch_dsl/test_faceted_search.py/test_filters_are_applied_to_search_ant_relevant_facets/swapped operands of `in`