Install Marvel Marvel | Monitor Elasticsearch
Documentation html
Install marvel by command line:
plugin -i elasticsearch/marvel/latest
To access by url: http://localhost:9200/_plugin/marvel/sense/index.html
Sense (Beta) is a plugin for Google Chrome chrome web store
List all indexes
GET _cat/indices?v
Get mapping from an index (playlist example)
GET playlist/_mapping
Delete an index
DELETE /playlist/
Match by name (mysql "like") (match)
GET playlist/_search { "query": { "match": { "name": "wish" } } }
Query limit 0,2 (from/size)
GET playlist/_search { "from" : 0, "size" : 2, "query": { "match": { "name": "Rock" } } }
Contains "Rock" and not "About" and not "Cherub"... (bool)
GET playlist/_search { "from" : 0, "size" : 10, "query": { "bool": { "must": { "match": { "name": "Rock" }}, "must_not": { "match": { "name": "About" }}, "must_not": { "match": { "name": "Cherub" }}, "must_not": { "match": { "name": "Ages" }} } } }
Contains "Rock" and not "Music" in playListName
GET playlist/_search { "from" : 0, "size" : 100, "query": { "bool": { "must": { "match": { "name": "Rock" }}, "must_not": { "match": { "playListName": "Music" }} } } }
Exact word, id = 5 (Term)
GET playlist/_search { "query": { "term": { "id": 5 } } }
Mysql id "in"
GET playlist/_search { "query": { "terms": { "id": [2, 4, 100] } } }
Ranges (Range)
GET playlist/_search { "query": { "filtered": { "filter": { "range": { "album.id": { "gt": 2, "lte": 5 } } } } } }
Suggestion (fuzzy)
The fuzzy query generates all possible matching terms that are within the maximum edit distance specified in fuzziness and then checks the term dictionary to find out which of those generated terms actually exist in the index.
GET /playlist/_search { "query": { "match": { "name": { "query": "Madana", "fuzziness": 2 } } } }
POST track_index/_search { "query": { "bool": { "must": [ { "match": { "composer": { "query": "Alanis Morisette", "fuzziness": 2 } } } ] } } }
Order (sorting)
GET playlist/_search?from=0&size=20 { "from" : 0, "size" : 20, "query": { "match_all": {} }, "sort": {"id":{"order":"asc"}} }
Sorting fields Not Analyzed Sorting collations
Set another field with "index" "not_analyzed" in the mapping and assign the same value at the data loading process:
'name' => [ 'type' => 'string', 'include_in_all' => true ], 'name_not_analyzed' => [ 'type' => 'string', "index" => "not_analyzed" ],
And then sort by the new field:
"sort": [ { "name_not_analyzed": { "order": "asc" } } ]
OST track_index/_search { "query": { "bool": { "must": [ { "match": { "composer": { "query": "Alanis Morisette", "fuzziness": 2 } } } ] } }, "highlight" : { "pre_tags" : ["<strong>"], "post_tags" : ["</strong>"], "fields" : { "composer" : {} } } }