When I run the below code I'm running the following in error in Elasticsearch:
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.
Elasticsearch dependency is "@elastic/elasticsearch": "7.6.1"
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'
}
}
}
}
}
}
});