<commit_before>import flask
import re

def filter_dsl_from_multidict(multidict):
    # Split the filters between 'range' and 'bool'
    bool_filter_keys = [k for k in multidict.keys() if re.compile("^filter_(?!range_)").match(k)]
    range_filter_keys = [k for k in multidict.keys() if re.compile("^filter_range_").match(k)]

    dsl = {}
    if bool_filter_keys or range_filter_keys:
        dsl["and"] = []
    if bool_filter_keys:
        bool_clause = {"bool":{"must":[], "should":[], "must_not":[]}}
        for key in bool_filter_keys:
            field = key.replace('filter_', '')
            values = multidict.getlist(key)
            for val in values:<commit_msg>Only include filters in ES query if they have values<commit_after>import flask
import re

def filter_dsl_from_multidict(multidict):
    # Split the filters between 'range' and 'bool', making sure the query value isn't blank
    bool_filter_keys = [r for r in [k for k in multidict.keys() if re.compile("^filter_(?!range_)").match(k)] \
                         if multidict[r]]
    range_filter_keys = [r for r in [k for k in multidict.keys() if re.compile("^filter_range_").match(k)] \
                         if multidict[r]]

    dsl = {}
    if bool_filter_keys or range_filter_keys:
        dsl["and"] = []
    if bool_filter_keys:
        bool_clause = {"bool":{"must":[], "should":[], "must_not":[]}}
        for key in bool_filter_keys:
            field = key.replace('filter_', '')
            values = multidict.getlist(key)
            for val in values:
{'fraction_non_alphanumeric': 0.13359273670557717, 'fraction_numerical': 0.0, 'mean_word_length': 2.8866498740554154, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2683941', 'n_tokens_mistral': 499, 'n_tokens_neox': 479, 'n_words': 133}