Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
elastic-builder: how to combine boolquery with rangequery in one query?

Basically, I have a request to search for documents with specific tag(s) attached in create range between given startDate and endDate. I use below code for query

createBoolQuery(): Query {
    return (
      esb
        .boolQuery()
        .filter(esb.termsQuery("tags", ["tag1", "tag2", "tag3"]))
    );
  }
createRangeQuery(): Query {
      const query = esb.rangeQuery("createdDate");
      if (this._rangeStartDate) {
        const startDate = moment(this._rangeStartDate);
        query.gte(startDate.format("MM/DD/YYYY"));
      }
      if (this._rangeEndDate) {
        const endDate = moment(this._rangeEndDate);
        query.lte(endDate.format("MM/DD/YYYY"));
      }

      return query;
  }
const query 

const searchQuery = esb.RequestBodySearch().query(this.createBoolQuery()).query(this.createRangeQuery())

searchQuery in above code is

query: {range: {createdDate: {gte: "09/29/2021", lte: "11/03/2021"}}}

which you can see boolQuery part is missing, however if I replace code to use boolquery only, like

const searchQuery = esb.RequestBodySearch().query(this.createBoolQuery())

then the searchQuery is

query: {filter: {terms: {tags: ["tag1", "tag2", "tag3"]}}}}

Need big help to use just one query including both boolQuery and rangeQuery.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda