Skip to content

Instantly share code, notes, and snippets.

@jonatasmaxi
Created August 29, 2018 13:55
Show Gist options
  • Select an option

  • Save jonatasmaxi/6badfc862498fd94be28efa4f9968b52 to your computer and use it in GitHub Desktop.

Select an option

Save jonatasmaxi/6badfc862498fd94be28efa4f9968b52 to your computer and use it in GitHub Desktop.
Filter by Metadata
/**
* Constrói a query de elastic search para buscar as transações que possuem os cashiersIds informados
* @param {[String]} cashiersId Informe os IDs dos cashiers que deseja encontrar as transações
*/
export const buildCashierQuery = cashiersId => {
const elasticQuery = {
query: {
constant_score: {
filter: {
bool: {
must: [
{ terms: { 'metadata.cashier_id': cashiersId } },
{ term: { status: 'paid' }}
]
}
}
}
},sort: [
{
date_created: { order: 'desc' },
},
],
size: 10000
};
return { type: 'transaction', query: JSON.stringify(elasticQuery) };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment