Skip to content

Instantly share code, notes, and snippets.

@hpainter
Created May 18, 2017 19:32
Show Gist options
  • Save hpainter/47024bab3a8dd0ac260a04965c6d5be8 to your computer and use it in GitHub Desktop.
Save hpainter/47024bab3a8dd0ac260a04965c6d5be8 to your computer and use it in GitHub Desktop.
es query demo
query.bool.filter.push({
"bool": {
// top-level status term group...doc must match one of these 'shoulds'
"should": [
// Available status
{
"bool": {
"must": [
{"term": { "status": "Available"}},
{"bool": { "should": [
// user created appt
{"term": { "creator_id": req.user.id }},
// user is specialist in originator private ntwk (include dynamically)
{"term": { "originator_id": req.user.person.organizations.map( (o) => o.id ) } }
] } }
]
}
},
// Claimed status
// ...
// Not one of the above statuses
{"bool": {"must_not": ["Available","Claimed","..."]}}
]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment