Skip to content

Instantly share code, notes, and snippets.

@xeraa
Created August 27, 2019 11:11
Show Gist options
  • Save xeraa/ec8264b97e876cac5f303641add0095d to your computer and use it in GitHub Desktop.
Save xeraa/ec8264b97e876cac5f303641add0095d to your computer and use it in GitHub Desktop.
GET /
GET /_analyze
{
"analyzer": "english",
"text": "These are not the droids you are looking for."
}
GET /_analyze
{
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"snowball"
],
"text": "These are <em>not</em> the droids you are looking for."
}
GET /_analyze
{
"analyzer": "german",
"text": "Das sind nicht die Droiden, nach denen du suchst."
}
GET /_analyze
{
"analyzer": "english",
"text": "Das sind nicht die Droiden, nach denen du suchst."
}
GET /_analyze
{
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"snowball"
],
"text": "Obi-Wan never told you what happened to your father."
}
GET /_analyze
{
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"snowball"
],
"text": "<b>No</b>. I am your father."
}
PUT /starwars
{
"settings": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"father,dad",
"droid => droid,machine"
]
}
},
"analyzer": {
"my_analyzer": {
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"snowball",
"my_synonym_filter"
]
}
}
}
},
"mappings": {
"properties": {
"quote": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
GET /starwars/_mapping
GET /starwars/_settings
PUT /starwars/_doc/1
{
"quote": "These are <em>not</em> the droids you are looking for."
}
PUT /starwars/_doc/2
{
"quote": "Obi-Wan never told you what happened to your father."
}
PUT /starwars/_doc/3
{
"quote": "<b>No</b>. I am your father."
}
GET /starwars/_doc/1
GET /starwars/_source/1
POST /starwars/_search
{
"query": {
"match_all": { }
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "Droid"
}
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "dad"
}
}
}
POST /starwars/_explain/0
{
"query": {
"match": {
"quote": "father"
}
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "machine"
}
}
}
POST /starwars/_search
{
"query": {
"match_phrase": {
"quote": "I am your father"
}
}
}
POST /starwars/_search
{
"query": {
"match_phrase": {
"quote": {
"query": "I am not your father",
"slop": 1
}
}
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": {
"query": "van",
"fuzziness": "AUTO"
}
}
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": {
"query": "ovi-van",
"fuzziness": 1
}
}
}
}
POST /starwars/_search?explain=true
{
"query": {
"match": {
"quote": "father"
}
}
}
POST /starwars/_search
{
"size": 1,
"query": {
"function_score": {
"query": {
"match": {
"quote": "father"
}
},
"random_score": {}
}
}
}
POST /starwars/_search
{
"size": 1,
"query": {
"script_score": {
"query": {
"match": {
"quote": "father"
}
},
"script": {
"source": "randomScore(1, '_id')"
}
}
}
}
GET /starwars/_analyze
{
"analyzer" : "my_analyzer",
"text": "These are my father's machines."
}
PUT /starwars/_doc/4
{
"quote": "These are my father's machines."
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "my father machine"
}
}
}
DELETE /starwars/_doc/4
POST /starwars/_search
{
"query": {
"match": {
"quote": "my father machine"
}
}
}
PUT /starwars/_doc/4
{
"quote": "These droids are my father's father's machines."
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "my father machine"
}
}
}
DELETE /starwars/_doc/4
POST /starwars/_search
{
"query": {
"match": {
"quote": "dad"
}
},
"highlight": {
"type": "unified",
"pre_tags": [
"<tag>"
],
"post_tags": [
"</tag>"
],
"fields": {
"quote": {}
}
}
}
POST /starwars/_search
{
"query": {
"bool": {
"must": {
"match": {
"quote": "father"
}
},
"should": [
{
"match": {
"quote": "your"
}
},
{
"match": {
"quote": "obi"
}
}
]
}
}
}
POST /starwars/_search
{
"query": {
"bool": {
"filter": {
"match": {
"quote": "father"
}
},
"should": [
{
"match": {
"quote": "your"
}
},
{
"match": {
"quote": "obi"
}
}
]
}
}
}
POST /starwars/_search
{
"query": {
"bool": {
"must": {
"match": {
"quote": "father"
}
},
"should": [
{
"match": {
"quote": {
"query": "your",
"_name": "quote-your"
}
}
},
{
"match": {
"quote": {
"query": "obi",
"_name": "quote-obi"
}
}
},
{
"match": {
"quote": {
"query": "droid",
"_name": "quote-droid"
}
}
}
],
"minimum_should_match": 2
}
}
}
POST /starwars/_search
{
"query": {
"bool": {
"must": {
"match": {
"quote": "father"
}
},
"should": [
{
"match": {
"quote": "your"
}
},
{
"match": {
"quote": {
"query": "obi",
"boost": 3
}
}
}
]
}
}
}
POST /starwars/_search
{
"query": {
"match": {
"quote": "drui"
}
},
"suggest": {
"my_suggestion" : {
"text" : "drui",
"term" : {
"field" : "quote"
}
}
}
}
GET /_analyze
{
"char_filter": [
"html_strip"
],
"tokenizer": {
"type": "ngram",
"min_gram": "3",
"max_gram": "3",
"token_chars": [
"letter"
]
},
"filter": [
"lowercase"
],
"text": "These are <em>not</em> the droids you are looking for."
}
GET /_analyze
{
"char_filter": [
"html_strip"
],
"tokenizer": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "3",
"token_chars": [
"letter"
]
},
"filter": [
"lowercase"
],
"text": "These are <em>not</em> the droids you are looking for."
}
PUT /starwars_v42
{
"settings": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"droid,machine",
"father,dad"
]
},
"my_ngram_filter": {
"type": "ngram",
"min_gram": "3",
"max_gram": "3",
"token_chars": [
"letter"
]
}
},
"analyzer": {
"my_lowercase_analyzer": {
"char_filter": [
"html_strip"
],
"tokenizer": "whitespace",
"filter": [
"lowercase"
]
},
"my_full_analyzer": {
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"stop",
"snowball",
"my_synonym_filter"
]
},
"my_ngram_analyzer": {
"char_filter": [
"html_strip"
],
"tokenizer": "whitespace",
"filter": [
"lowercase",
"stop",
"my_ngram_filter"
]
}
}
}
},
"mappings": {
"properties": {
"quote": {
"type": "text",
"fields": {
"lowercase": {
"type": "text",
"analyzer": "my_lowercase_analyzer"
},
"full": {
"type": "text",
"analyzer": "my_full_analyzer"
},
"ngram": {
"type": "text",
"analyzer": "my_ngram_analyzer"
}
}
}
}
}
}
POST /_reindex
{
"source": {
"index": "starwars"
},
"dest": {
"index": "starwars_v42"
}
}
PUT _alias
{
"actions": [
{
"add": {
"index": "starwars_v42",
"alias": "starwars_extended"
}
}
]
}
POST /starwars_extended/_search?explain=true
{
"query": {
"multi_match": {
"query": "obiwan",
"fields": [
"quote",
"quote.lowercase",
"quote.full",
"quote.ngram"
],
"type": "most_fields"
}
}
}
POST /starwars_extended/_search
{
"query": {
"multi_match": {
"query": "you",
"fields": [
"quote",
"quote.lowercase",
"quote.full^5",
"quote.ngram"
],
"type": "best_fields"
}
}
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote.ngram": {
"query": "the",
"analyzer": "standard"
}
}
}
}
POST /starwars_extended/_close
PUT /starwars_extended/_settings
{
"analysis": {
"filter": {
"my_edgegram_filter": {
"type": "edge_ngram",
"min_gram": 3,
"max_gram": 10
}
},
"analyzer": {
"my_edgegram_analyzer": {
"char_filter": [
"html_strip"
],
"tokenizer": "standard",
"filter": [
"lowercase",
"my_edgegram_filter"
]
}
}
}
}
POST /starwars_extended/_open
GET starwars_extended/_analyze
{
"text": "Father",
"analyzer": "my_edgegram_analyzer"
}
PUT /starwars_extended/_mapping
{
"properties": {
"quote": {
"type": "text",
"fields": {
"edgegram": {
"type": "text",
"analyzer": "my_edgegram_analyzer",
"search_analyzer": "standard"
}
}
}
}
}
PUT /starwars_extended/_doc/4
{
"quote": "I find your lack of faith disturbing."
}
PUT /starwars_extended/_doc/5
{
"quote": "That... is your failure."
}
GET /starwars_extended/_termvectors/4
{
"fields": [
"quote.edgegram"
],
"offsets": true,
"payloads": true,
"positions": true,
"term_statistics": true,
"field_statistics": true
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote": "fail"
}
}
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote.lowercase": "fail"
}
}
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote.full": "fail"
}
}
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote.ngram": "fail"
}
}
}
POST /starwars_extended/_search
{
"query": {
"match": {
"quote.edgegram": "fail"
}
}
}
PUT _alias
{
"actions": [
{
"remove": {
"index": "starwars_v42",
"alias": "starwars_extended"
}
}
]
}
DELETE /starwars
DELETE /starwars_v42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment