Skip to content

Instantly share code, notes, and snippets.

@ranjitiyer
Last active November 15, 2017 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranjitiyer/34091f4641db5aa67b4e1895a9d2dc64 to your computer and use it in GitHub Desktop.
Save ranjitiyer/34091f4641db5aa67b4e1895a9d2dc64 to your computer and use it in GitHub Desktop.
Elastic Search Cheat Sheet
# Delete docs that do not exactly match a phrase
POST audiobooks/book/_delete_by_query
{
"query": {
"bool": {
"must_not": [
{"match_phrase": {
"language": "English"
}}
]
}
}
}
# Search docs that do not exactly match a phrase
GET audiobooks/book/_search
{
"query": {
"bool": {
"must_not": [
{"match_phrase": {
"language": "English"
}}
]
}
}
}
# Search docs exactly match a phrase
GET audiobooks/book/_search
{
"query": {
"bool": {
"must": [
{"match_phrase": {
"language": "English"
}}
]
}
}
}
# Get all docs that have a field
GET audiobooks/book/_search
{
"query": {
"bool": {
"must": {
"exists": {
"field": "sections.url"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment