Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!