Cuando ejecuto el siguiente código, estoy ejecutando lo siguiente por error en la búsqueda elástica:
Invalid alias name [...] must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?]
No me gusta que esté usando index1,index2 como mi índice (también probé index : [index1, index2]
Este código funciona en Kibana cuando lo ejecuto en la misma fuente de datos.
La dependencia de Elastic Search es "@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' } } } } } } });