<commit_before>##Install Marvel [Marvel | Monitor Elasticsearch](https://www.elastic.co/products/marvel)

Documentation [html](https://www.elastic.co/guide/en/marvel/current/index.html)

Install marvel by command line:

<pre>
 plugin -i elasticsearch/marvel/latest
</pre>

To access by url:
http://localhost:9200/_plugin/marvel/sense/index.html

###Elasticsearch Queries:

Sense (Beta) is a plugin for Google Chrome [chrome web store](https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig)

List all indexes
<pre>
GET _cat/indices?v
</pre>

Get mapping from an index (playlist example)
<pre>
    GET playlist/_mapping
</pre>


Delete an index
<pre>
    DELETE /playlist/
</pre>

Match by name (mysql "like") ([match](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-match-query.html))

<pre>
GET playlist/_search
{
  "query": {
    "match": {
      "name": "wish"
    }
  }
}
</pre>

Query limit 0,2 ([from/size](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html))

<pre>
GET playlist/_search
{
  "from" : 0, "size" : 2, 
  "query": {
    "match": {
      "name": "Rock"
    }
  }
}
</pre>

Contains "Rock" and not "About" and not "Cherub"... ([bool](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html))

<pre>
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" }}
    }
  }
}
</pre>

Contains "Rock" and not "Music" in playListName

<pre>
GET playlist/_search
{
  "from" : 0, "size" : 100, 
  "query": {
    "bool": {
      "must": { "match": { "name": "Rock" }},
      "must_not": { "match": { "playListName":  "Music" }}
    }
  }
}
</pre>

##Filter

Exact word, id = 5 ([Term](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html))

<pre>
GET playlist/_search
{
  "query": {
    "term": {
      "id": 5
    }
  }
}

</pre>

Mysql id "in" 

<pre>
GET playlist/_search
{
  "query": {
    "terms": { "id": [2, 4, 100] }
  }
}
</pre>

Ranges ([Range](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html))

<pre>
GET playlist/_search
{<commit_msg>Update queries-and-marvel.md<commit_after>## Install Marvel [Marvel | Monitor Elasticsearch](https://www.elastic.co/products/marvel)

Documentation [html](https://www.elastic.co/guide/en/marvel/current/index.html)

Install marvel by command line:

<pre>
 plugin -i elasticsearch/marvel/latest
</pre>

To access by url:
http://localhost:9200/_plugin/marvel/sense/index.html

### Elasticsearch Queries:

Sense (Beta) is a plugin for Google Chrome [chrome web store](https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig)

List all indexes
<pre>
GET _cat/indices?v
</pre>

Get mapping from an index (playlist example)
<pre>
    GET playlist/_mapping
</pre>


Delete an index
<pre>
    DELETE /playlist/
</pre>

Match by name (mysql "like") ([match](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-match-query.html))

<pre>
GET playlist/_search
{
  "query": {
    "match": {
      "name": "wish"
    }
  }
}
</pre>

Query limit 0,2 ([from/size](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html))

<pre>
GET playlist/_search
{
  "from" : 0, "size" : 2, 
  "query": {
    "match": {
      "name": "Rock"
    }
  }
}
</pre>

Contains "Rock" and not "About" and not "Cherub"... ([bool](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html))

<pre>
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" }}
    }
  }
}
</pre>

Contains "Rock" and not "Music" in playListName

<pre>
GET playlist/_search
{
  "from" : 0, "size" : 100, 
  "query": {
    "bool": {
      "must": { "match": { "name": "Rock" }},
      "must_not": { "match": { "playListName":  "Music" }}
    }
  }
}
</pre>

## Filter

Exact word, id = 5 ([Term](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html))

<pre>
GET playlist/_search
{
  "query": {
    "term": {
      "id": 5
    }
  }
}

</pre>

Mysql id "in" 

<pre>
GET playlist/_search
{
  "query": {
    "terms": { "id": [2, 4, 100] }
  }
}
</pre>

Ranges ([Range](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html))

<pre>
GET playlist/_search
{
{'fraction_non_alphanumeric': 0.19870455495194317, 'fraction_numerical': 0.010029251984956121, 'mean_word_length': 3.351818181818182, 'pattern_counts': {'":': 68, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 16, 'lorem ipsum': 0, 'www.': 14, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '398518', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1852, 'n_words': 366}