<commit_before>import getFunctionScores from './elasticsearch/score'
import getMultiMatchConfig from './elasticsearch/multimatch'
import getBoosts from './elasticsearch/boost'
import getMapping from './elasticsearch/mapping'
import cloneDeep from 'lodash-es/cloneDeep'
import config from 'config'

export async function prepareElasticsearchQueryBody (searchQuery) {
  const bodybuilder = await import(/* webpackChunkName: "bodybuilder" */ 'bodybuilder')
  const optionsPrfeix = '_options'
  const queryText = searchQuery.getSearchText()
  const rangeOperators = ['gt', 'lt', 'gte', 'lte', 'moreq', 'from', 'to']
  let query = bodybuilder.default()

  // process applied filters
  const appliedFilters = cloneDeep(searchQuery.getAppliedFilters()) // copy as function below modifies the object
  if (appliedFilters.length > 0) {
    let hasCatalogFilters = false

    // apply default filters
    appliedFilters.forEach(filter => {
      if (filter.scope === 'default') {
        if (rangeOperators.every(rangeOperator => filter.value.hasOwnProperty(rangeOperator))) {
          // process range filters
          query = query.filter('range', filter.attribute, filter.value)
        } else {<commit_msg>Fix range queries to elasticsearch<commit_after>import getFunctionScores from './elasticsearch/score'
import getMultiMatchConfig from './elasticsearch/multimatch'
import getBoosts from './elasticsearch/boost'
import getMapping from './elasticsearch/mapping'
import cloneDeep from 'lodash-es/cloneDeep'
import config from 'config'

export async function prepareElasticsearchQueryBody (searchQuery) {
  const bodybuilder = await import(/* webpackChunkName: "bodybuilder" */ 'bodybuilder')
  const optionsPrfeix = '_options'
  const queryText = searchQuery.getSearchText()
  const rangeOperators = ['gt', 'lt', 'gte', 'lte', 'moreq', 'from', 'to']
  let query = bodybuilder.default()

  // process applied filters
  const appliedFilters = cloneDeep(searchQuery.getAppliedFilters()) // copy as function below modifies the object
  if (appliedFilters.length > 0) {
    let hasCatalogFilters = false

    // apply default filters
    appliedFilters.forEach(filter => {
      if (filter.scope === 'default') {
        if (Object.keys(filter.value).every(v => rangeOperators.includes(v))) {
          // process range filters
          query = query.filter('range', filter.attribute, filter.value)
        } else {
{'fraction_non_alphanumeric': 0.11420265780730897, 'fraction_numerical': 0.0008305647840531562, 'mean_word_length': 4.329646017699115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '128478', 'n_tokens_mistral': 643, 'n_tokens_neox': 653, 'n_words': 186}