Created
December 6, 2016 02:27
-
-
Save eyeezzi/aadf8ce98f93a633e9b5c4d062490393 to your computer and use it in GitHub Desktop.
Some operations on Elasticsearch using the Kibana Console query DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the recommended way to do complex queries. | |
GET /firebase/event/_search | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ "multi_match": { | |
"query": "pride parade", | |
"fields": ["title", "description"] | |
}} | |
], | |
"must_not": [], | |
"should": [ | |
{ "geo_distance": { | |
"distance": "5km", | |
"distance_type": "plane", | |
"location": { "lat": 49.25107, "lon": -122.86388 } | |
}} | |
], | |
"filter": { | |
"bool": { | |
"must": [ | |
{ "term": { "price": 0 }}, | |
{ "terms": { "categories": ["music", "sports"] }}, | |
{ "terms": { "moods": ["happy", "fun"] }}, | |
{ "range": { | |
"startDate": { "gte": "05/12/2016" } | |
}}, | |
{ "range": { | |
"endDate": { "lte": "01/01/2017" } | |
}} | |
] | |
} | |
} | |
} | |
} | |
} | |
# a template index for indices with name starting with 'firebase' | |
PUT /_template/firebase | |
{ | |
"template": "firebase*", | |
"settings": {}, | |
"mappings": { | |
"event": { | |
"dynamic_templates": [ | |
{ "geolocation": { | |
"match": "location", | |
"mapping": { "type": "geo_point" } | |
}}, | |
{ "ints": { | |
"match": "price", | |
"mapping": { "type": "long" } | |
}}, | |
{ "dates": { | |
"match_pattern": "regex", | |
"match": "(startDate|endDate)", | |
"mapping": { "type": "date", "format": "dd/MM/yyyy" } | |
}}, | |
{ "noIndex": { | |
"match_pattern": "regex", | |
"match": "(hostId|hostImageUrl|thumbnailUrl)", | |
"mapping": { "type": "string", "index": "no" } | |
}} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment