How to use the elastic-builder.multiMatchQuery function in elastic-builder

To help you get started, we’ve selected a few elastic-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dpc-sdp / ripple / packages / ripple-nuxt-tide / modules / search / lib / search / services / elasticsearch / lib / querybuilder.js View on Github external
if (item.length > 0) {
            return item
          }
        })
        // Match any terms.
        esbResult = esbResult.filter(esb.termsQuery(filterName, filterVals))
        // Match all terms.
        // esbResult = esbResult.should(esb.termsQuery(filterName, filterVals))
        // esbResult = esbResult.minimumShouldMatch(filterField.length)
      } else {
        let filterField = filter.values.slice()
        esbResult = esbResult.filter(esb.termQuery(filterName, filterField))
      }
      break
    case 'multiMatch':
      esbResult = esbResult.must(esb.multiMatchQuery(filter.fields, filter.values))
      break
    case 'ids':
      esbResult = esbResult.filter(esb.idsQuery(filter.fields, filter.values))
      break
    case 'integer':
      esbResult = esbResult.filter(esb.rangeQuery(filterName)[operator](filter.values))
      break
    default:
  }
}
github dpc-sdp / ripple / packages / ripple-nuxt-tide / modules / search / lib / search / services / elasticsearch / lib / querybuilder.js View on Github external
getEsQueryBody: function (queryString, filters, fields, exclude) {
    let esbResult = {}
    if (queryString === false) {
      esbResult = esb.boolQuery().must(esb.matchAllQuery())
    } else if (exclude) {
      let excludes = [
        esb.termQuery('type', exclude.type)
      ]
      if (exclude.field) {
        excludes.push(esb.existsQuery(exclude.field))
      }
      esbResult = esb.boolQuery().must([
        esb.multiMatchQuery(fields, queryString),
        esb.boolQuery().mustNot(esb.boolQuery().must(excludes))
      ])
    } else {
      esbResult = esb.boolQuery().must(esb.multiMatchQuery(fields, queryString))
    }

    if (Object.keys(filters).length > 0) {
      for (let filterName in filters) {
        addFilter(esbResult, filters[filterName], filterName)
      }
    }
    return esb.requestBodySearch().query(
      esbResult
    )
  },
github dpc-sdp / ripple / packages / ripple-nuxt-tide / modules / search / lib / search / services / elasticsearch / lib / querybuilder.js View on Github external
let esbResult = {}
    if (queryString === false) {
      esbResult = esb.boolQuery().must(esb.matchAllQuery())
    } else if (exclude) {
      let excludes = [
        esb.termQuery('type', exclude.type)
      ]
      if (exclude.field) {
        excludes.push(esb.existsQuery(exclude.field))
      }
      esbResult = esb.boolQuery().must([
        esb.multiMatchQuery(fields, queryString),
        esb.boolQuery().mustNot(esb.boolQuery().must(excludes))
      ])
    } else {
      esbResult = esb.boolQuery().must(esb.multiMatchQuery(fields, queryString))
    }

    if (Object.keys(filters).length > 0) {
      for (let filterName in filters) {
        addFilter(esbResult, filters[filterName], filterName)
      }
    }
    return esb.requestBodySearch().query(
      esbResult
    )
  },