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

111
Vistas
Error in Elastic Search in Javasctipt - Querying against multiple indexes

When I run the below code I'm running the following in error in elastic search:

Invalid alias name [...] must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?]

It doesn't like that I'm using index1,index2 as my index (I've also tried index : [index1, index2]

This code works in Kibana when I run it against the same data source.

Elastic Search dependency is "@elastic/elasticsearch": "7.6"

  const { client } = context; // context from graphql resolver

  const query = buildQuery({
    id: id,
    queryIndex: `${index1},${index2}`;
  });

  const results = await client.search(query);

  export const buildQuery = ({ id. queryIndex }) => ({
      index: queryIndex,
      body: {
        query: {
          bool: {
            must: [
              {
                terms: {
                  'someId': [id]
                }
              }
            ]
          }
        },
        aggs: {
          byindex: {
            terms: {
              field: '_index'
            },
            aggs: {
              min_date: {
                min: {
                  field: 'date',
                  format: 'yyyy-MM-dd'
                }
              },
              max_date: {
                max: {
                  field: 'date',
                  format: 'yyyy-MM-dd'
                }
              }
            }
          }
        }
      }
    });
    
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