Skip to content

Instantly share code, notes, and snippets.

@arifmahmudrana
Last active July 21, 2020 06: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 arifmahmudrana/25f66d06a4920236ff5f518da7e14a11 to your computer and use it in GitHub Desktop.
Save arifmahmudrana/25f66d06a4920236ff5f518da7e14a11 to your computer and use it in GitHub Desktop.
Elastic search queries
POST tasks/_doc
{
"title": "Goto ICCDRB",
"description": "I will goto ICCDRB with my mother for her urine test & ultrasonogram test",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
GET tasks/_mapping
GET tasks/_search
PUT tasks/_doc/b_mDCm8BwTUfNAv5iAwY
{
"title": "Elasticsearch learn",
"description": "Watch video of elasticsearch",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
PUT tasks/_doc/b_mDCm8BwTUfNAv5iAwZ
{
"title": "Copy downloaded",
"description": "Copy all the downloaded files to my USB harddrive",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
GET tasks/_doc/b_mDCm8BwTUfNAv5iAwZ/_source?_source_includes=*.id,title&_source_excludes=description
GET tasks/_doc/b_mDCm8BwTUfNAv5iAwZ
POST tasks/_doc/b_mDCm8BwTUfNAv5iAwZ/_update
{
"doc": {
"title": "Copy downloaded files",
"user" : {
"verified" : true
}
}
}
DELETE tasks/_doc/b_mDCm8BwTUfNAv5iAwZ
POST tasks/_doc/b_mDCm8BwTUfNAv5iAwZ/_update
{
"title": "Copy downloaded",
"description": "Copy all the downloaded files to my USB harddrive",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
GET tasks/_doc/b_mDCm8BwTUfNAv5iAwZ
POST tasks/_doc/b_mDCm8BwTUfNAv5iAwZ/_update
{
"script": "ctx._source.title = 'New value'",
"upsert": {
"title": "Copy downloaded",
"description": "Copy all the downloaded files to my USB harddrive",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
}
POST tasks/_update_by_query
{
"script": "ctx._source.done = false"
}
POST tasks/_doc/b_mDCm8BwTUfNAv5iAwZ/_update
{
"script": "ctx._source.title = 'New value'; ctx._source.done = true",
"upsert": {
"title": "Copy downloaded",
"description": "Copy all the downloaded files to my USB harddrive",
"user": {
"id": 1,
"name": "Arif Mahmud Rana",
"email": "arif_mahmud_rana@hotmail.com"
}
}
}
POST tasks/_delete_by_query
{
"query": {
"match": {
"done": false
}
}
}
DELETE tasks
POST tasks/_doc/_bulk
{ "index" : { "_id" : "b_mDCm8BwTUfNAv5iAwZ" } }
{ "title": "Copy downloaded", "description": "Copy all the downloaded files to my USB harddrive", "user": { "id": 1, "name": "Arif Mahmud Rana", "email": "arif_mahmud_rana@hotmail.com" } }
{ "update" : {"_id" : "b_mDCm8BwTUfNAv5iAwZ"} }
{ "doc" : {"title": "Copy downloaded???"} }
GET products/_search
GET _cat/health?v
GET _cat/nodes?v
GET _cat/allocation?v
GET _cat/shards?v
PUT tasks?pretty
GET products/_mapping
PUT products/_doc/_mapping
{
"properties": {
"discount": {
"type": "double"
}
}
}
DELETE products
PUT products
{
"mappings": {
"_doc": {
"dynamic": false,
"properties": {
"in_stock": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"price": {
"type": "integer"
},
"sold": {
"type": "long"
}
}
}
}
}
PUT products/_doc/_mapping
{
"properties": {
"discount": {
"type": "double"
}
}
}
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"city": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}
}
}
PUT my_index/_doc/1
{
"city": "New York"
}
PUT my_index/_doc/2
{
"city": "York"
}
GET my_index/_search
GET my_index/_search
{
"query": {
"match": {
"city": "york"
}
},
"sort": {
"city.raw": "asc"
},
"aggs": {
"Cities": {
"terms": {
"field": "city.raw"
}
}
}
}
DELETE my_index
GET _cat/indices?v
PUT products/_doc/_mapping
{
"properties": {
"description": {
"type": "text"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
PUT products/_doc/_mapping
{
"properties": {
"created": {
"type": "date",
"format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
}
}
}
PUT products/_doc/2000
{
"description": "Test",
"discount": 20
}
PUT products/_doc/_mapping
{
"properties": {
"discount": {
"type": "integer"
}
}
}
GET products/_search
{
"query": {
"match": {
"description": "Test"
}
}
}
GET products/_search
{
"query": {
"term": {
"discount": 20
}
}
}
POST products/_update_by_query?conflicts=proceed
DELETE products/_doc/2000
POST _analyze
{
"tokenizer": "standard",
"text": "I'm in the mood for drinking semi-dry red wine!"
}
POST _analyze
{
"tokenizer": "standard",
"filter": [
"lowercase"
],
"text": "I'm in the mood for drinking semi-dry red wine!"
}
POST _analyze
{
"filter": [
"lowercase"
],
"text": "I'm in the mood for drinking semi-dry red wine!"
}
POST _analyze
{
"analyzer": "standard",
"text": "I'm in the mood for drinking semi-dry red wine!"
}
GET _analyze
{
"tokenizer": "whitespace",
"filter": [
"lowercase",
{
"type": "stop",
"stopwords": [
"a",
"is",
"this"
]
}
],
"text": "this IS a TEST"
}
POST _analyze
{
"tokenizer": "keyword",
"char_filter": [ "html_strip" ],
"text": "<p>I&apos;m so <b>happy</b>!</p>"
}
POST _analyze
{
"tokenizer": "whitespace",
"text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}
POST _analyze
{
"tokenizer": "letter",
"text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}
POST _analyze
{
"tokenizer": "lowercase",
"text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}
GET _analyze
{
"tokenizer": "standard",
"filter": [
"ngram",
{
"type": "stop",
"stopwords": [
"Quick"
]
}
],
"text": "Quick fox"
}
PUT analyzers_test
{
"settings": {
"analysis": {
"analyzer": {
"english_stop": {
"type": "standard",
"stopwords": "_english_"
}
},
"filter": {
"my_stemmer": {
"type": "stemmer",
"name": "english"
}
}
}
}
}
GET analyzers_test/_analyze
{
"analyzer": "english_stop",
"text": "I'm in the mood for drinking semi-dry red wine!"
}
GET analyzers_test/_analyze
{
"tokenizer": "standard",
"filter": [
"my_stemmer"
],
"text": "I'm in the mood for drinking semi-dry red wine!"
}
DELETE analyzers_test
PUT analyzers_test
{
"settings": {
"analysis": {
"filter": {
"my_stemmer": {
"type": "stemmer",
"name": "english"
}
},
"analyzer": {
"english_stop": {
"type": "standard",
"stopwords": "_english_"
},
"my_analyzer": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [
"html_strip"
],
"filter": [
"lowercase",
"trim",
"my_stemmer"
]
}
}
}
}
}
GET analyzers_test/_analyze
{
"analyzer": "my_analyzer",
"text": "I'm in the mood for drinking <strong>semi-dry</strong> red wine!"
}
PUT analyzers_test/_doc/_mapping
{
"properties": {
"description": {
"type": "text",
"analyzer": "my_analyzer"
},
"teaser": {
"type": "text",
"analyzer": "standard"
}
}
}
POST analyzers_test/_doc/1
{
"description": "drinking",
"teaser": "drinking"
}
GET analyzers_test/_search
GET analyzers_test/_search
{
"query": {
"term": {
"teaser": {
"value": "drinking"
}
}
}
}
GET analyzers_test/_doc/_search
{
"query": {
"term": {
"description": {
"value": "drinking"
}
}
}
}
GET analyzers_test/_mapping
POST analyzers_test/_close
PUT analyzers_test/_settings
{
"analysis": {
"analyzer": {
"french_stop": {
"type": "standard",
"stopwords": "_french_"
}
}
}
}
POST analyzers_test/_open
GET analyzers_test/_settings
GET products/_search?q=*
GET products/_search?q=name:Lobster
GET products/_search?q=tags:Meat
GET products/_search?q=tags:Meat AND name:Tuna
GET products/_search?q=tags:Meat OR name:Tuna
GET products/_search
{
"query": {
"match_all": {}
}
}
GET products/_search
{
"explain": true,
"query": {
"term": {
"name": "lobster"
}
}
}
GET products/_doc/1/_explain
{
"query": {
"term": {
"name": "lobster"
}
}
}
GET products/_doc/1/_explain
{
"query": {
"term": {
"name": "wine"
}
}
}
GET products/_search
{
"query": {
"term": {
"name": "lobster"
}
}
}
GET products/_search
{
"query": {
"term": {
"name": "Lobster"
}
}
}
GET products/_search
{
"query": {
"match": {
"name": "Lobster"
}
}
}
GET products/_search
{
"query": {
"term": {
"is_active": true
}
}
}
GET products/_search
{
"query": {
"term": {
"is_active": {
"value": true
}
}
}
}
GET products/_search
{
"query": {
"terms": {
"tags.keyword": [ "Soup", "Cake" ]
}
}
}
GET products/_search
{
"query": {
"ids": {
"values": [ 1, 2, 3 ]
}
}
}
GET products/_search
{
"query": {
"range": {
"in_stock": {
"gte": 1,
"lte": 5
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "2010/01/01",
"lte": "2010/12/31"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "01-01-2010",
"lte": "31-12-2010",
"format": "dd-MM-yyyy"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "2010/01/01||-1y"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "2010/01/01||-1y-1d"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "2010/01/01||-1y/M"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "2010/01/01||/M-1y"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "now/M-1y"
}
}
}
}
GET products/_search
{
"query": {
"range": {
"created": {
"gte": "now"
}
}
}
}
GET products/_search
{
"query": {
"exists": {
"field": "tags"
}
}
}
GET products/_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "tags"
}
}
}
}
}
GET products/_search
{
"query": {
"prefix": {
"tags.keyword": "Vege"
}
}
}
GET products/_search
{
"query": {
"prefix": {
"name.keyword": "Pot"
}
}
}
GET products/_search
{
"query": {
"wildcard": {
"tags.keyword": "Veg*ble"
}
}
}
GET products/_search
{
"query": {
"wildcard": {
"tags.keyword": "Veg?ble"
}
}
}
GET products/_search
{
"query": {
"wildcard": {
"tags.keyword": "Veget?ble"
}
}
}
GET products/_search
{
"query": {
"regexp": {
"tags.keyword": "Veg[a-zA-Z]+ble"
}
}
}
GET recipe/_mapping
GET recipe/_search
GET /recipe/_search
{
"query": {
"match": {
"title": "Recipes with pasta or spaghetti"
}
}
}
GET /recipe/_search
{
"query": {
"match": {
"title": {
"query": "Recipes with pasta or spaghetti",
"operator": "and"
}
}
}
}
GET /recipe/_search
{
"query": {
"match": {
"title": {
"query": "pasta or spaghetti",
"operator": "and"
}
}
}
}
GET /recipe/_search
{
"query": {
"match": {
"title": {
"query": "pasta spaghetti",
"operator": "and"
}
}
}
}
GET /recipe/_search
{
"query": {
"match_phrase": {
"title": "spaghetti puttanesca"
}
}
}
GET /recipe/_search
{
"query": {
"match_phrase": {
"title": "puttanesca spaghetti"
}
}
}
GET /recipe/_search
{
"query": {
"multi_match": {
"query": "pasta",
"fields": [ "title", "description" ]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": "parmesan"
}
},
{
"range": {
"preparation_time_minutes": {
"lte": 15
}
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": "parmesan"
}
}
],
"filter": [
{
"range": {
"preparation_time_minutes": {
"lte": 15
}
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": "parmesan"
}
}
],
"must_not": [
{
"match": {
"ingredients.name": "tuna"
}
}
],
"filter": [
{
"range": {
"preparation_time_minutes": {
"lte": 15
}
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": "parmesan"
}
}
],
"must_not": [
{
"match": {
"ingredients.name": "tuna"
}
}
],
"should": [
{
"match": {
"ingredients.name": "parsley"
}
}
],
"filter": [
{
"range": {
"preparation_time_minutes": {
"lte": 15
}
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": "pasta"
}
}
],
"should": [
{
"match": {
"ingredients.name": "parmesan"
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"ingredients.name": "parmesan"
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"ingredients.name": {
"query": "parmesan",
"_name": "parmesan_must"
}
}
}
],
"must_not": [
{
"match": {
"ingredients.name": {
"query": "tuna",
"_name": "tuna_must_not"
}
}
}
],
"should": [
{
"match": {
"ingredients.name": {
"query": "parsley",
"_name": "parsley_should"
}
}
}
],
"filter": [
{
"range": {
"preparation_time_minutes": {
"lte": 15,
"_name": "prep_time_filter"
}
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"match": {
"title": "pasta carbonara"
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"should": [
{
"term": {
"title": "pasta"
}
},
{
"term": {
"title": "carbonara"
}
}
]
}
}
}
GET /recipe/_search
{
"query": {
"match": {
"title": {
"query": "pasta carbonara",
"operator": "and"
}
}
}
}
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"title": "pasta"
}
},
{
"term": {
"title": "carbonara"
}
}
]
}
}
}
PUT /department
{
"mappings": {
"_doc": {
"properties": {
"name": {
"type": "text"
},
"employees": {
"type": "nested"
}
}
}
}
}
PUT /department/_doc/1
{
"name": "Development",
"employees": [
{
"name": "Eric Green",
"age": 39,
"gender": "M",
"position": "Big Data Specialist"
},
{
"name": "James Taylor",
"age": 27,
"gender": "M",
"position": "Software Developer"
},
{
"name": "Gary Jenkins",
"age": 21,
"gender": "M",
"position": "Intern"
},
{
"name": "Julie Powell",
"age": 26,
"gender": "F",
"position": "Intern"
},
{
"name": "Benjamin Smith",
"age": 46,
"gender": "M",
"position": "Senior Software Engineer"
}
]
}
PUT /department/_doc/2
{
"name": "HR & Marketing",
"employees": [
{
"name": "Patricia Lewis",
"age": 42,
"gender": "F",
"position": "Senior Marketing Manager"
},
{
"name": "Maria Anderson",
"age": 56,
"gender": "F",
"position": "Head of HR"
},
{
"name": "Margaret Harris",
"age": 19,
"gender": "F",
"position": "Intern"
},
{
"name": "Ryan Nelson",
"age": 31,
"gender": "M",
"position": "Marketing Manager"
},
{
"name": "Kathy Williams",
"age": 49,
"gender": "F",
"position": "Senior Marketing Manager"
},
{
"name": "Jacqueline Hill",
"age": 28,
"gender": "F",
"position": "Junior Marketing Manager"
},
{
"name": "Donald Morris",
"age": 39,
"gender": "M",
"position": "SEO Specialist"
},
{
"name": "Evelyn Henderson",
"age": 24,
"gender": "F",
"position": "Intern"
},
{
"name": "Earl Moore",
"age": 21,
"gender": "M",
"position": "Junior SEO Specialist"
},
{
"name": "Phillip Sanchez",
"age": 35,
"gender": "M",
"position": "SEM Specialist"
}
]
}
GET /department/_search
{
"query": {
"nested": {
"path": "employees",
"query": {
"bool": {
"must": [
{
"match": {
"employees.position": "intern"
}
},
{
"term": {
"employees.gender.keyword": {
"value": "F"
}
}
}
]
}
}
}
}
}
GET /department/_search
{
"query": {
"nested": {
"path": "employees",
"query": {
"bool": {
"must": [
{
"match": {
"employees.position": "intern"
}
},
{
"term": {
"employees.gender.keyword": "F"
}
}
]
}
}
}
}
}
GET /department/_mapping
GET /department/_search
GET /department/_search
{
"_source": false,
"query": {
"nested": {
"path": "employees",
"inner_hits": {},
"query": {
"bool": {
"must": [
{
"match": {
"employees.position": "intern"
}
},
{
"term": {
"employees.gender.keyword": {
"value": "F"
}
}
}
]
}
}
}
}
}
DELETE /department
PUT /department
{
"mappings": {
"_doc": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"department": "employee"
}
}
}
}
}
}
PUT /department/_doc/1
{
"name": "Development",
"join_field": "department"
}
PUT /department/_doc/2
{
"name": "Marketing",
"join_field": "department"
}
PUT /department/_doc/3?routing=1
{
"name": "Bo Andersen",
"age": 28,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 1
}
}
PUT /department/_doc/4?routing=2
{
"name": "John Doe",
"age": 44,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 2
}
}
PUT /department/_doc/5?routing=1
{
"name": "James Evans",
"age": 32,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 1
}
}
PUT /department/_doc/6?routing=1
{
"name": "Daniel Harris",
"age": 52,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 1
}
}
PUT /department/_doc/7?routing=2
{
"name": "Jane Park",
"age": 23,
"gender": "F",
"join_field": {
"name": "employee",
"parent": 2
}
}
PUT /department/_doc/8?routing=1
{
"name": "Christina Parker",
"age": 29,
"gender": "F",
"join_field": {
"name": "employee",
"parent": 1
}
}
PUT /department/_doc/9
{
"name": "IT",
"join_field": "department"
}
PUT /department/_doc/3?routing=9
{
"name": "Rana",
"age": 37,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 9
}
}
PUT /department/_doc/3?routing=9
{
"name": "Sakib",
"age": 33,
"gender": "M",
"join_field": {
"name": "employee",
"parent": 9
}
}
GET /department/_search
{
"query": {
"parent_id": {
"type": "employee",
"id": 9
}
}
}
GET /department/_search
{
"query": {
"has_parent": {
"parent_type": "department",
"query": {
"term": {
"name.keyword": "Development"
}
}
}
}
}
GET /department/_search
{
"query": {
"has_parent": {
"parent_type": "department",
"score": true,
"query": {
"term": {
"name.keyword": "Development"
}
}
}
}
}
GET /department/_search
{
"query": {
"has_child": {
"type": "employee",
"query": {
"bool": {
"must": [
{
"range": {
"age": {
"gte": 50
}
}
}
],
"should": [
{
"term": {
"gender.keyword": "M"
}
}
]
}
}
}
}
}
GET /department/_search
{
"query": {
"has_child": {
"type": "employee",
"score_mode": "sum",
"query": {
"bool": {
"must": [
{
"range": {
"age": {
"gte": 50
}
}
}
],
"should": [
{
"term": {
"gender.keyword": "M"
}
}
]
}
}
}
}
}
GET /department/_search
{
"query": {
"has_child": {
"type": "employee",
"score_mode": "sum",
"min_children": 2,
"max_children": 5,
"query": {
"bool": {
"must": [
{
"range": {
"age": {
"gte": 50
}
}
}
],
"should": [
{
"term": {
"gender.keyword": "M"
}
}
]
}
}
}
}
}
PUT /company
{
"mappings": {
"_doc": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"company": [
"department",
"supplier"
],
"department": "employee"
}
}
}
}
}
}
PUT /company/_doc/1
{
"name": "My Company Inc.",
"join_field": "company"
}
PUT /company/_doc/2?routing=1
{
"name": "Development",
"join_field": {
"name": "department",
"parent": 1
}
}
PUT /company/_doc/3?routing=1
{
"name": "Bo Andersen",
"join_field": {
"name": "employee",
"parent": 2
}
}
PUT /company/_doc/4
{
"name": "Another Company, Inc.",
"join_field": "company"
}
PUT /company/_doc/5?routing=4
{
"name": "Marketing",
"join_field": {
"name": "department",
"parent": 4
}
}
PUT /company/_doc/6?routing=4
{
"name": "John Doe",
"join_field": {
"name": "employee",
"parent": 5
}
}
GET /company/_search
{
"query": {
"has_child": {
"type": "department",
"query": {
"has_child": {
"type": "employee",
"query": {
"term": {
"name.keyword": "John Doe"
}
}
}
}
}
}
}
GET /department/_search
{
"query": {
"has_child": {
"type": "employee",
"inner_hits": {},
"query": {
"bool": {
"must": [
{
"range": {
"age": {
"gte": 50
}
}
}
],
"should": [
{
"term": {
"gender.keyword": "M"
}
}
]
}
}
}
}
}
GET /department/_search
{
"query": {
"has_parent": {
"inner_hits": {},
"parent_type": "department",
"query": {
"term": {
"name.keyword": "Development"
}
}
}
}
}
PUT /users/_doc/1
{
"name": "John Roberts",
"following" : [2, 3]
}
PUT /users/_doc/2
{
"name": "Elizabeth Ross",
"following" : []
}
PUT /users/_doc/3
{
"name": "Jeremy Brooks",
"following" : [1, 2]
}
PUT /users/_doc/4
{
"name": "Diana Moore",
"following" : [3, 1]
}
PUT /stories/_doc/1
{
"user": 3,
"content": "Wow look, a penguin!"
}
PUT /stories/_doc/2
{
"user": 1,
"content": "Just another day at the office... #coffee"
}
PUT /stories/_doc/3
{
"user": 1,
"content": "Making search great again! #elasticsearch #elk"
}
PUT /stories/_doc/4
{
"user": 4,
"content": "Had a blast today! #rollercoaster #amusementpark"
}
PUT /stories/_doc/5
{
"user": 4,
"content": "Yay, I just got hired as an Elasticsearch consultant - so excited!"
}
PUT /stories/_doc/6
{
"user": 2,
"content": "Chilling at the beach @ Greece #vacation #goodtimes"
}
GET /stories/_search
{
"query": {
"terms": {
"user": {
"index": "users",
"type": "_doc",
"id": 1,
"path": "following"
}
}
}
}
GET /recipe/_search?format=yaml
{
"query": {
"match": {
"title": "pasta"
}
}
}
GET /recipe/_search?pretty
{
"query": {
"match": {
"title": "pasta"
}
}
}
GET /recipe/_search
{
"_source": false,
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search
{
"_source": "created",
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search
{
"_source": "ingredients.name",
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search
{
"_source": "ingredients.*",
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search
{
"_source": [ "ingredients.*", "servings" ],
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search
{
"_source": {
"includes": "ingredients.*",
"excludes": "ingredients.name"
},
"query": {
"match": { "title": "pasta" }
}
}
GET /recipe/_search?size=2
{
"_source": false,
"query": {
"match": {
"title": "pasta"
}
}
}
GET /recipe/_search
{
"_source": false,
"size": 2,
"query": {
"match": {
"title": "pasta"
}
}
}
GET /recipe/_search
{
"_source": false,
"size": 2,
"from": 2,
"query": {
"match": {
"title": "pasta"
}
}
}
GET /recipe/_search
{
"_source": false,
"query": {
"match_all": {}
},
"sort": "preparation_time_minutes"
}
GET /recipe/_search
{
"_source": false,
"query": {
"match_all": {}
},
"sort": [
"preparation_time_minutes"
]
}
GET /recipe/_search
{
"_source": "created",
"query": {
"match_all": {}
},
"sort": [
{
"created": "desc"
}
]
}
GET /recipe/_search
{
"_source": [
"preparation_time_minutes",
"created"
],
"query": {
"match_all": {}
},
"sort": [
{
"preparation_time_minutes": "asc"
},
{
"created": "desc"
}
]
}
GET /recipe/_search
{
"_source": [
"preparation_time_minutes",
"created"
],
"query": {
"match_all": {}
},
"sort": [
"preparation_time_minutes",
{
"created": "desc"
}
]
}
GET /recipe/_search
{
"_source": "ratings",
"query": {
"match_all": {}
}
}
GET /recipe/_search
{
"_source": "ratings",
"query": {
"match_all": {}
},
"sort": [
{
"ratings": {
"order": "desc",
"mode": "avg"
}
}
]
}
GET /recipe/_doc/5
GET /recipe/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "pasta"
}
}
],
"filter": [
{
"range": {
"preparation_time_minutes": {
"lte": 15
}
}
}
]
}
}
}
PUT /order
{
"mappings": {
"_doc": {
"properties": {
"purchased_at": {
"type": "date"
},
"lines": {
"type": "nested",
"properties": {
"product_id": {
"type": "integer"
},
"amount": {
"type": "double"
},
"quantity": {
"type": "short"
}
}
},
"total_amount": {
"type": "double"
},
"status": {
"type": "keyword"
},
"sales_channel": {
"type": "keyword"
},
"salesman": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "text"
}
}
}
}
}
}
}
GET /order/_mapping
GET /order/_search
GET /order/_doc/14
GET /order/_search
{
"size": 0,
"aggs": {
"total_sales": {
"sum": {
"field": "total_amount"
}
},
"avg_sale": {
"avg": {
"field": "total_amount"
}
},
"min_sale": {
"min": {
"field": "total_amount"
}
},
"max_sale": {
"max": {
"field": "total_amount"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"total_salesmen": {
"cardinality": {
"field": "salesman.id"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"values_count": {
"value_count": {
"field": "total_amount"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"amount_stats": {
"stats": {
"field": "total_amount"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"status_terms": {
"terms": {
"field": "status"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"status_terms": {
"terms": {
"field": "total_amount",
"size": 20
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"status_terms": {
"terms": {
"field": "status",
"size": 20,
"missing": "N/A",
"min_doc_count": 0
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"status_terms": {
"terms": {
"field": "status",
"size": 20,
"missing": "N/A",
"min_doc_count": 0,
"order": {
"_key": "asc"
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"status_terms": {
"terms": {
"field": "status"
},
"aggs": {
"status_stats": {
"stats": {
"field": "total_amount"
}
}
}
}
}
}
GET /order/_search
{
"size": 0,
"query": {
"range": {
"total_amount": {
"gte": 100
}
}
},
"aggs": {
"status_terms": {
"terms": {
"field": "status"
},
"aggs": {
"status_stats": {
"stats": {
"field": "total_amount"
}
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"low_value": {
"filter": {
"range": {
"total_amount": {
"lt": 50
}
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"low_value": {
"filter": {
"range": {
"total_amount": {
"lt": 50
}
}
},
"aggs": {
"avg_amount": {
"avg": {
"field": "total_amount"
}
}
}
}
}
}
GET /recipe/_search
{
"size": 0,
"aggs": {
"my_filter": {
"filters": {
"filters": {
"pasta": {
"match": {
"title": "pasta"
}
},
"spaghetti": {
"match": {
"title": "spaghetti"
}
}
}
}
}
}
}
GET /recipe/_search
{
"size": 0,
"aggs": {
"my_filter": {
"filters": {
"filters": {
"pasta": {
"match": {
"title": "pasta"
}
},
"spaghetti": {
"match": {
"title": "spaghetti"
}
}
}
},
"aggs": {
"avg_rating": {
"avg": {
"field": "ratings"
}
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"amount_distribution": {
"range": {
"field": "total_amount",
"ranges": [
{
"to": 50
},
{
"from": 50,
"to": 100
},
{
"from": 100
}
]
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"purchased_ranges": {
"date_range": {
"field": "purchased_at",
"ranges": [
{
"from": "2016-01-01",
"to": "2016-01-01||+6M"
},
{
"from": "2016-01-01||+6M",
"to": "2016-01-01||+1y"
}
]
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"purchased_ranges": {
"date_range": {
"field": "purchased_at",
"format": "yyyy-MM-dd",
"ranges": [
{
"from": "2016-01-01",
"to": "2016-01-01||+6M"
},
{
"from": "2016-01-01||+6M",
"to": "2016-01-01||+1y"
}
]
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"purchased_ranges": {
"date_range": {
"field": "purchased_at",
"format": "yyyy-MM-dd",
"keyed": true,
"ranges": [
{
"from": "2016-01-01",
"to": "2016-01-01||+6M"
},
{
"from": "2016-01-01||+6M",
"to": "2016-01-01||+1y"
}
]
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"purchased_ranges": {
"date_range": {
"field": "purchased_at",
"format": "yyyy-MM-dd",
"keyed": true,
"ranges": [
{
"from": "2016-01-01",
"to": "2016-01-01||+6M",
"key": "first_half"
},
{
"from": "2016-01-01||+6M",
"to": "2016-01-01||+1y",
"key": "second_half"
}
]
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"purchased_ranges": {
"date_range": {
"field": "purchased_at",
"format": "yyyy-MM-dd",
"keyed": true,
"ranges": [
{
"from": "2016-01-01",
"to": "2016-01-01||+6M",
"key": "first_half"
},
{
"from": "2016-01-01||+6M",
"to": "2016-01-01||+1y",
"key": "second_half"
}
]
},
"aggs": {
"bucket_stats": {
"stats": {
"field": "total_amount"
}
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"amount_distribution": {
"histogram": {
"field": "total_amount",
"interval": 25
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"amount_distribution": {
"histogram": {
"field": "total_amount",
"interval": 25,
"min_doc_count": 1
}
}
}
}
GET /order/_search
{
"size": 0,
"query": {
"range": {
"total_amount": {
"gte": 100
}
}
},
"aggs": {
"amount_distribution": {
"histogram": {
"field": "total_amount",
"interval": 25,
"min_doc_count": 0,
"extended_bounds": {
"min": 0,
"max": 500
}
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"orders_over_time": {
"date_histogram": {
"field": "purchased_at",
"interval": "month"
}
}
}
}
GET /order/_search
{
"size": 0,
"aggs": {
"orders_over_time": {
"date_histogram": {
"format": "yyyy-MM-dd",
"keyed": true,
"field": "purchased_at",
"interval": "month"
}
}
}
}
GET /order/_search
{
"query": {
"range": {
"total_amount": {
"gte": 100
}
}
},
"size": 0,
"aggs": {
"all_orders": {
"global": { },
"aggs": {
"stats_amount": {
"stats": {
"field": "total_amount"
}
}
}
}
}
}
GET /order/_search
{
"query": {
"range": {
"total_amount": {
"gte": 100
}
}
},
"size": 0,
"aggs": {
"all_orders": {
"global": { },
"aggs": {
"stats_amount": {
"stats": {
"field": "total_amount"
}
}
}
},
"stats_expensive": {
"stats": {
"field": "total_amount"
}
}
}
}
POST /order/_doc/1001
{
"total_amount": 100
}
POST /order/_doc/1002
{
"total_amount": 200,
"status": null
}
GET /order/_doc/_search
{
"size": 0,
"aggs": {
"orders_without_status": {
"missing": {
"field": "status"
}
}
}
}
GET /order/_doc/_search
{
"size": 0,
"aggs": {
"orders_without_status": {
"missing": {
"field": "status"
},
"aggs": {
"missing_sum": {
"sum": {
"field": "total_amount"
}
}
}
}
}
}
DELETE /order/_doc/1001
DELETE /order/_doc/1002
GET /department/_search
{
"size": 0,
"aggs": {
"employees": {
"nested": {
"path": "employees"
}
}
}
}
GET /department/_search
{
"size": 0,
"aggs": {
"employees": {
"nested": {
"path": "employees"
},
"aggs": {
"minimum_age": {
"min": {
"field": "employees.age"
}
}
}
}
}
}
PUT /proximity/_doc/1
{
"title": "Spicy Sauce"
}
PUT /proximity/_doc/2
{
"title": "Spicy Tomato Sauce"
}
PUT /proximity/_doc/3
{
"title": "Spicy Tomato and Garlic Sauce"
}
PUT /proximity/_doc/4
{
"title": "Tomato Sauce (spicy)"
}
PUT /proximity/_doc/5
{
"title": "Spicy and very delicious Tomato Sauce"
}
GET /proximity/_search
{
"query": {
"match_phrase": {
"title": {
"query": "spicy sauce",
"slop": 1
}
}
}
}
GET /proximity/_search
{
"query": {
"match_phrase": {
"title": {
"query": "spicy sauce",
"slop": 2
}
}
}
}
GET /proximity/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": {
"query": "spicy sauce"
}
}
}
]
}
}
}
GET /proximity/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": {
"query": "spicy sauce"
}
}
}
],
"should": [
{
"match_phrase": {
"title": {
"query": "spicy sauce"
}
}
}
]
}
}
}
GET /proximity/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": {
"query": "spicy sauce"
}
}
}
],
"should": [
{
"match_phrase": {
"title": {
"query": "spicy sauce",
"slop": 5
}
}
}
]
}
}
}
GET /products/_search
{
"query": {
"match": {
"name": {
"query": "l0bster",
"fuzziness": "auto"
}
}
}
}
GET /products/_search
{
"query": {
"match": {
"name": {
"query": "lobster",
"fuzziness": "auto"
}
}
}
}
GET /products/_search
{
"query": {
"match": {
"name": {
"query": "l0bster love",
"operator": "and",
"fuzziness": 1
}
}
}
}
GET /products/_search
{
"query": {
"match": {
"name": {
"query": "lvie",
"fuzziness": 1
}
}
}
}
GET /products/_search
{
"query": {
"match": {
"name": {
"query": "lvie",
"fuzziness": 1,
"fuzzy_transpositions": false
}
}
}
}
GET /products/_search
{
"query": {
"fuzzy": {
"name": {
"value": "LOBSTER",
"fuzziness": "auto"
}
}
}
}
GET /products/_search
{
"query": {
"fuzzy": {
"name": {
"value": "LOBSTER",
"fuzziness": "auto"
}
}
}
}
GET /products/_search
{
"query": {
"fuzzy": {
"name": {
"value": "lobster",
"fuzziness": "auto"
}
}
}
}
PUT /synonyms
{
"settings": {
"analysis": {
"filter": {
"synonym_test": {
"type": "synonym",
"synonyms": [
"awful => terrible",
"awesome => great, super",
"elasticsearch, logstash, kibana => elk",
"weird, strange"
]
}
},
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"synonym_test"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"description": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
}
POST /synonyms/_analyze
{
"analyzer": "my_analyzer",
"text": "awesome"
}
POST /synonyms/_analyze
{
"analyzer": "my_analyzer",
"text": "Elasticsearch"
}
POST /synonyms/_analyze
{
"analyzer": "my_analyzer",
"text": "weird"
}
POST /synonyms/_analyze
{
"analyzer": "my_analyzer",
"text": "Elasticsearch is awesome, but can also seem weird sometimes."
}
POST /synonyms/_doc
{
"description": "Elasticsearch is awesome, but can also seem weird sometimes."
}
GET /synonyms/_search
{
"query": {
"match": {
"description": "great"
}
}
}
GET /synonyms/_search
{
"query": {
"match": {
"description": "awesome"
}
}
}
PUT /highlighting/_doc/1
{
"description": "Let me tell you a story about Elasticsearch. It's a full-text search engine that is built on Apache Lucene. It's really easy to use, but also packs lots of advanced features that you can use to tweak its searching capabilities. Lots of well-known and established companies use Elasticsearch, and so should you!"
}
GET /highlighting/_search
{
"_source": false,
"query": {
"match": { "description": "Elasticsearch story" }
},
"highlight": {
"fields": {
"description" : {}
}
}
}
GET /highlighting/_search
{
"_source": false,
"query": {
"match": { "description": "Elasticsearch story" }
},
"highlight": {
"pre_tags": [ "<strong>" ],
"post_tags": [ "</strong>" ],
"fields": {
"description" : {}
}
}
}
PUT /stemming_test
{
"settings": {
"analysis": {
"filter": {
"synonym_test": {
"type": "synonym",
"synonyms": [
"firm => company",
"love, enjoy"
]
},
"stemmer_test" : {
"type" : "stemmer",
"name" : "english"
}
},
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"synonym_test",
"stemmer_test"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"description": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
}
POST /stemming_test/_doc/1
{
"description": "I love working for my firm!"
}
GET /stemming_test/_search
{
"query": {
"match": {
"description": "enjoy work"
}
}
}
GET /stemming_test/_search
{
"query": {
"match": {
"description": "love working"
}
}
}
GET /stemming_test/_search
{
"query": {
"match": {
"description": "enjoy work"
}
},
"highlight": {
"fields": {
"description": {}
}
}
}
GET /shakespeare/_search
{
"query": {
"match_phrase": {
"text_entry": "to be or not to be"
}
}
}
DELETE /my_date_test
PUT /my_date_test
{
"mappings": {
"_doc": {
"properties": {
"rating_at": {
"type": "date"
}
}
}
}
}
PUT /my_date_test/_doc/1
{
"rating_at": 964982703
}
GET /my_date_test/_search
{
"query": {
"range" : {
"rating_at" : {
"lt" : "now/d"
}
}
}
}
GET /my_date_test
GET /my_date_test/_search
{
"query": {
"range" : {
"rating_at" : {
"lt" : "2019-02-28"
}
}
}
}
PUT my_index/_doc/1
{
"message": "some arrays in this document...",
"tags": [ "elasticsearch", "wow" ],
"lists": [
{
"name": "prog_list",
"description": "programming list"
},
{
"name": "cool_list",
"description": "cool stuff list"
}
]
}
GET /my_index
DELETE /movies
PUT /movies
{
"mappings": {
"_doc": {
"properties": {
"movieId": {
"type": "long"
},
"imdbId": {
"type": "long"
},
"tmdbId": {
"type": "long"
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above" : 256
}
}
},
"year": {
"type": "short"
},
"genres" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"ratings": {
"type": "nested",
"properties": {
"userId": {
"type": "long"
},
"rating": {
"type": "half_float"
},
"timestamp": {
"type": "date"
}
}
},
"tags": {
"type": "nested",
"properties": {
"userId": {
"type": "long"
},
"tag" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"timestamp": {
"type": "date"
}
}
},
"enabled": {
"type": "boolean"
}
}
}
}
}
PUT /movies/_doc/1
{
"movieId": 1,
"imdbId": 1,
"tmdbId": 1,
"title": "Toy Story",
"year": 1995,
"genres": [
"Adventure", "Animation", "Children", "Comedy"
],
"ratings": [
{
"userId": 1,
"rating": 4,
"timestamp": 964982703
}
],
"tags": [
{
"userId": 1,
"tag": "funny",
"timestamp": 1445714994
}
]
}
PUT /movies/_doc/2
{
"movieId": 2,
"imdbId": 2,
"tmdbId": 2,
"title": "Jumanji",
"year": 1995,
"genres": [
"Adventure","Children","Fantasy"
],
"enabled": true
}
GET /movies/_doc/1
POST /movies/_doc/1/_update
{
"script": {
"source": "ctx._source.genres.add(params.genre)",
"params": {
"genre": "Fantasy"
}
}
}
POST /movies/_doc/1/_update
{
"script": {
"source": "ctx._source.enabled = false"
}
}
POST /movies/_doc/1/_update
{
"script" : "ctx._source.remove('enabled')"
}
GET /movies/_search
{
"size": 3,
"aggs": {
"enabled": {
"terms": {
"field": "enabled"
}
}
},
"script_fields": {
"enabled": {
"script": {
"lang": "painless",
"source": "doc['enabled'].value"
}
}
}
}
GET /movies/_search
GET /movies/_doc/2
POST /movies/_doc/2/_update
{
"script" : "ctx._source.remove('ratings')"
}
POST /movies/_doc/2/_update
{
"script": {
"source": "ctx._source.ratings = [params.rating]",
"params": {
"rating": {
"userId": 2,
"rating": 4.5,
"timestamp": 994982703
}
}
}
}
POST /movies/_doc/2/_update
{
"script": {
"source": "if (!ctx._source.containsKey('ratings')) { ctx._source.ratings = [params.rating] } else { ctx._source.ratings.add(params.rating) }",
"params": {
"rating": {
"userId": 2,
"rating": 4.5,
"timestamp": 994982703
}
}
}
}
POST /movies/_doc/2/_update
{
"script": {
"source": "ctx._source.ratings.removeIf(rating -> rating.userId == params.userId)",
"params": {
"userId": 2
}
}
}
POST /movies/_doc/2/_update
{
"script": {
"source": """
for (int i = 0; i < ctx._source.ratings.length; ++i) {
if (ctx._source.ratings[i].userId == params.userId) {
ctx._source.ratings[i].rating = params.rating;
break;
}
}
""",
"params": {
"userId": 2,
"rating": 5
}
}
}
POST /movies/_doc/2/_update
{
"script": {
"source": "def targets = ctx._source.ratings; for(rating in targets) { if (rating.rating == params.userId) { rating.rating = params.rating } }",
"params": {
"userId": 2,
"rating": 4
}
}
}
PUT /test_index/_doc/1
{
"genres": [
"Adventure",
"Animation",
"Children",
"Comedy"
]
}
PUT /test_index/_doc/2
{
"genres": [
"Comedy"
]
}
GET /test_index
GET /test_index/_search
GET /test_index/_search?size=0
{
"aggs": {
"genres": {
"terms": {
"field": "genres.keyword",
"size" : 1
}
}
}
}
GET /kibana_sample_data_logs/_search
{
"size": 0,
"aggs": {
"ip_count": {
"value_count": {
"field": "clientip"
}
}
}
}
GET /kibana_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"unique_skus": {
"cardinality": {
"field": "sku"
}
}
}
}
GET /kibana_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"quantity_stats": {
"stats": {
"field": "total_quantity"
}
}
}
}
GET /kibana_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"User_based_filter": {
"filter": {
"term": {
"user": "eddie"
}
},
"aggs": {
"avg_price": {
"avg": {
"field": "products.price"
}
}
}
}
}
}
GET /kibana_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"User_based_filter": {
"filter": {
"term": {
"user": "eddie"
}
},
"aggs": {
"avg_price": {
"avg": {
"field": "products.price"
}
}
}
}
}
}
GET /kibana_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"Terms_Aggregation": {
"terms": {
"field": "user"
}
}
}
}
GET /movies/_search
GET /movies/_doc/2/_source
HEAD /movies/_doc/22
HEAD /movies
GET /movies/_search
{
"query": {
"match": {
"title": "jumanji"
}
}
}
GET /movies/_search
{
"query": {
"match_phrase_prefix": {
"title": "jum"
}
}
}
GET /movies/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "jumanji"
}
},
{
"match_phrase_prefix": {
"title": "jum"
}
}
]
}
}
}
GET /movies/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "jumanji"
}
},
{
"bool": {
"must": [
{
"match_phrase_prefix": {
"title": "jum"
}
}
]
}
}
]
}
}
}
GET /movies/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "Toy"
}
},
{
"match_phrase_prefix": {
"title": "J"
}
}
],
"should": [
{
"match": {
"title": "Jumanji"
}
},
{
"range": {
"year": {
"gte": 10,
"lte": 2020
}
}
}
],
"filter": {
"range": {
"year": {
"gte": 10000,
"lte": 20000
}
}
}
}
}
}
GET /movies/_search
{
"query": {
"ids": {
"values": ["1", "4", "100"]
}
}
}
GET /movies/_search
{
"size": 0,
"aggs": {
"resellers": {
"nested": {
"path": "ratings"
},
"aggs": {
"rating": {
"histogram": {
"field": "ratings.rating",
"interval": 1
}
},
"min_rating": {
"min": {
"field": "ratings.rating"
}
}
}
}
}
}
GET /niffler_property/_count
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "Pertschy Palais Hotel"
}
},
{
"match": {
"countryCode.keyword": "AT"
}
},
{
"match": {
"cityName": "Vienna"
}
}
],
"filter": [
{
"match": {
"type.keyword": "hotel"
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "Pertschy Palais Hotel"
}
},
{
"match": {
"countryCode.keyword": "AT"
}
},
{
"match": {
"cityName": "Vienna"
}
}
],
"filter": [
{
"match": {
"type.keyword": "hotel"
}
}
]
}
}
}
GET /xyz/_search?filter_path=hits.hits._source
{
"_source": {
"includes": "id"
},
"query": {
"match_all": {}
}
}
GET /xyz/_search
{
"_source": {
"includes": "id"
},
"query": {
"match_all": {}
}
}
GET /xyz/_mappings?include_type_name=true
PUT _template/template_1
{
"index_patterns": [
"te*"
],
"mappings": {
"_doc": {
"dynamic": false,
"properties": {
"name": {
"type": "keyword"
}
}
}
}
}
DELETE _template/template_1
DELETE /test
PUT /test/_doc/1
{
"name": "Hell",
"m": true
}
GET /test/_doc/1
GET /test
GET /test/_search
{
"query": {
"term": {
"m": true
}
}
}
DELETE /test
PUT /test2
{
"mappings": {
"doc": {
"dynamic": true,
"properties": {
"name1": {
"type": "keyword"
},
"name2": {
"type": "keyword"
}
}
}
}
}
PUT /test2/_doc/1
{
"name1": "Hell",
"name2": "World",
"m": true
}
GET /test2/_doc/1
GET /test2
GET /test2/_search
{
"query": {
"term": {
"m": true
}
}
}
GET _cat/indices //to get all indices
GET kibana_sample_data_ecommerce/_search?size=20&_source=false&from=25&sort=_score:desc //see all data
GET kibana_sample_data_ecommerce/_search
{
"query":{
"query_string":{
"query":"Yahya"
}
}
}
GET kibana_sample_data_ecommerc*/_search
{
"query":{
"query_string":{
"query":"MALE"
}
}
}
GET kibana_sample_data_ecommerc*/_search
{
"aggs":{
"avg_price":{"avg":{"field":"products.base_price"}}
}
}
GET /_cat/indices?v
GET /_cat/nodes?h=ip,port
GET _cat/templates?v&s=version:desc,index_patterns:asc
GET /_cat/count?v
GET /my_index/_search
{
"query":{
"match" : {
"user":"rana"
}
}
}
GET /my_index/_search
{
"sort" : [
{ "_score" : "asc" }
],
"query": {
"bool": {
"should": [
{ "match": { "user": "rana"}}
],
"must": [
{ "match": { "message": "Hello" }}
]
}
}
}
GET kibana_sample_data_ecommerce/_search
{
"query":{
"term":{"products.product_id":6283}
}
}
GET kibana_sample_data_ecommerce/_search
{
"query":{
"range": {
"products.product_id": {
"gte": 6000,
"lte": 7000
}
}
}
}
GET kibana_sample_data_ecommerce/_search
{
"sort" : [
{ "_score" : "desc" }
],
"query": {
"bool": {
"should": [
{
"range": {
"products.product_id": {
"gte": 6000,
"lte": 7000,
"boost": 100
}
}
}
]
}
}
}
PUT my_index/my_type/G123
{
"message": "Hello, World! How are you"
}
GET my_index/_mapping?include_type_name=true
GET my_index/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"message.keyword": "Hello World!"
}
}
],
"filter": [
{
"match": {
"message.keyword": "Hello World!"
}
}
]
}
}
}
GET my_index/_settings
GET kibana_sample_data_ecommerce/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"products.manufacturer.keyword": "Elitelligence"
}
},
{
"term": {
"products.price": 6.99
}
}
]
}
},
"sort": [
{
"_score": "desc"
}
],
"size": 14,
"_source": {
"includes": [
"products.price",
"products.manufacturer"
]
}
}
POST /index/type/100100471/_update
{
"doc" : {
"yourProperty" : 10000
}
}
GET niffler_property/_search?filter_path=-_shards,hits.hits._id,hits.hits._source
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "parentId"
}
},
{
"exists": {
"field": "createdAt"
}
}
]
}
}
}
GET niffler_property/_search
{
"query": {
"exists": {
"field": "fullAddress"
}
}
}
GET niffler_property/_search
{
"size": 10,
"sort": [
{
"userHits": {
"order": "desc"
}
},
"_score"
],
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": {
"bool": {
"must": [
{
"term": {
"isSearchable": true
}
},
{
"term": {
"type.keyword": "hotel"
}
}
],
"must_not": []
}
}
}
}
}
GET niffler_property/_search
{
"size": 10,
"sort": [
{
"userHits": {
"order": "desc"
}
},
"_score"
],
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"fullAddress": "russia"
}
}
],
"filter": {
"bool": {
"must": [
{
"term": {
"isSearchable": true
}
},
{
"term": {
"type.keyword": "hotel"
}
}
],
"must_not": []
}
}
}
}
}
GET niffler_property/_search
{
"size": 10,
"sort": [
{
"userHits": {
"order": "desc"
}
},
"_score"
],
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"fullAddress": "Thailand"
}
}
],
"filter": {
"bool": {
"must": [
{
"term": {
"isSearchable": true
}
}
],
"must_not": [
{
"term": {
"type.keyword": "hotel"
}
}
]
}
}
}
}
}
GET tour_city/_mappings?include_type_name=true
GET _cat/indices?v
GET niffler_property/_settings
GET niffler_property/_mapping
GET niffler_hotel/_settings
GET niffler_hotel/_mapping
GET niffler_property/_search
GET niffler_property/_doc/H474226
PUT test/_doc/1
{
"counter" : 1,
"tags" : ["red"]
}
POST test/_doc/1/_update
{
"script" : {
"source": "if(ctx._source.userHits != null) {ctx._source.userHits++ } else{ ctx._source.userHits=1}"
}
}
GET test/_doc/1
DELETE test
DELETE /grn_cities
PUT /grn_cities
{
"mappings": {
"doc": {
"dynamic": false,
"properties": {
"name": {
"type": "keyword"
}
}
}
}
}
PUT /grn_cities/doc/C!022725
{
"name": "Los Cacaos"
}
GET /grn_cities/_search
GET /grn_cities/doc/C!022725
GET /grn_cities/doc/C!022725/_source
GET /grn_cities/doc/C!022725
GET /_cat/indices?pretty&v
GET /niffler_hotel/_search?filter_path=hits.hits._source
{
"_source": {
"includes": "id"
},
"query": {
"match_all": {}
}
}
GET /niffler_hotel/_search
{
"_source": {
"includes": "id"
},
"query": {
"match_all": {}
}
}
GET /niffler_hotel/_mappings?include_type_name=true
PUT grn_hotels
{
"mappings": {
"doc": {
"dynamic": false,
"properties": {
"address": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"country_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"location": {
"type": "geo_point"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"postal_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"star_category": {
"type": "long"
},
"found": {
"type": "boolean"
}
}
}
}
}
GET /grn_hotels/_mapping
GET /grn_hotels/_search
GET /grn_cities/doc/C!090868
GET /grn_hotels/doc/H!0747337
DELETE /grn_hotels/_doc/H!0747337
GET /grn_hotels/_doc/H!0747337
PUT /grn_hotels/_doc/H!0747337
{
"name": "Hacienda La Danesa",
"description": "<p><b>Property Location</b> <br />With a stay at Hacienda La Danesa in Naranjito, you''ll be on a river, and 17.6 mi (28.2 km) from Agrarian University of Ecuador and 17.9 mi (28.8 km) from Leon Becerra Hospital. This 4-star hotel is 18 mi (28.9 km) from Milagro Central Park and 26 mi (41.9 km) from Santa Rosa Protected Forest.</p><p><b>Attractions</b> <br />Distances are displayed to the nearest 0.1 mile and kilometer. <br /> <p>Agrarian University of Ecuador - 28.2 km / 17.6 mi <br /> Leon Becerra Hospital - 28.8 km / 17.9 mi <br /> Milagro Central Park - 28.9 km / 18 mi <br /> Santa Rosa Protected Forest - 41.9 km / 26 mi <br /> </p><p>The preferred airport for Hacienda La Danesa is Guayaquil (GYE-Jose Joaquin de Olmedo Intl.) - 75 km / 46.6 mi </p></p><p><b>Amenities</b> <br />Treat yourself with massages and facials. You can take advantage of recreational amenities such as a lazy river and bicycles to rent. This hotel also features complimentary wireless Internet access, concierge services, and wedding services.</p><p><b>Business Amenities</b> <br />Featured amenities include a business center, dry cleaning/laundry services, and luggage storage. A train station pick-up service is provided at no charge (available 24 hours), and free self parking is available onsite.</p><p><b>Rooms</b> <br />Make yourself at home in one of the 6 air-conditioned rooms featuring flat-screen televisions. Your pillowtop bed comes with premium bedding. Complimentary wireless Internet access keeps you connected, and satellite programming is available for your entertainment. Bathrooms feature showers, designer toiletries, and bathrobes.</p><p><b>Dining</b> <br />All-inclusive rates are available at this hotel. Meals and beverages at onsite dining establishments are included in all-inclusive rates. Charges may be applied for dining at some restaurants, special dinners and dishes, some beverages, and other amenities. <p>Enjoy a meal at the restaurant, or stay in and take advantage of the hotel''s room service (during limited hours). Quench your thirst with your favorite drink at the bar/lounge. A complimentary cooked-to-order breakfast is served daily. </p></p>",
"city": "Naranjito",
"country_code": "EC",
"star_category": 4,
"address": "Autopista Naranjito Bucay km 67, Hacienda Nueva Fortuna, Naranjito, Guayas",
"postal_code": "",
"found": false
}
GET /grn_hotels/_search
{
"query": {
"ids" : {
"type" : "doc",
"values" : ["H!0747337", "H!0821560", "H!1121805", "H!0981579", "H!1148465", "H!0825119", "H!1036931", "H!1059201", "H!1163340", "H!0909377", "H!1129084", "H!1174092", "H!0795025", "H!0913137", "H!1043659", "H!0770374", "H!1128093", "H!0962673", "H!0947143", "H!0798833", "H!1183781", "H!0712484", "H!0998998", "H!1003413", "H!0925801", "H!1036448", "H!1211019", "H!0565652", "H!0697143", "H!0649702", "H!1136328", "H!1024361", "H!0918165", "H!0575772", "H!1138340", "H!0562487", "H!1138611", "H!1037283", "H!0824219", "H!0936469", "H!1191627", "H!1106488", "H!1161727", "H!1177589", "H!1212511", "H!0562757", "H!0566438", "H!0738811", "H!1076736", "H!0102257", "H!1067083", "H!1088535", "H!1132517", "H!0575988", "H!0874516", "H!1180227", "H!0576598", "H!1040084", "H!1182494", "H!0746121", "H!1057170", "H!1127471", "H!0921326", "H!0574026", "H!0712147", "H!1026847", "H!1030292", "H!1088626", "H!1107952", "H!0958772", "H!0946562", "H!0578517", "H!0956883", "H!0926996", "H!1164330", "H!0995437", "H!0726258", "H!0796335", "H!0907734", "H!1037479", "H!1123602", "H!1012591", "H!0803718", "H!1166529", "H!1136113", "H!0941960", "H!1022904", "H!1102807", "H!0574254", "H!1122377", "H!1056417", "H!0576424", "H!0563225", "H!0850907", "H!0944188", "H!1085329", "H!0709345", "H!1165832", "H!1084893", "H!1109140", "H!0564406"]
}
}
}
GET /grn_hotels/_search
GET niffler_property/doc/H971267
GET /niffler_property/_mapping
GET /_search/scroll
{
"scroll" : "1m",
"scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
}
GET /grn_hotels/_search?scroll=1m
{
"from": 0,
"size": 1,
"_source": {
"includes": [
"name",
"city",
"country_code",
"location"
]
},
"query": {
"bool": {
"must": [
{
"term": {
"found": false
}
},
{
"exists": {
"field": "location"
}
}
]
}
}
}
GET /grn_hotels/_count
{
"query": {
"bool": {
"must": [
{
"term": {
"found": false
}
},
{
"exists": {
"field": "location"
}
}
]
}
}
}
GET /grn_hotels/_count
{
"query": {
"bool": {
"must": [
{
"term": {
"found": false
}
}
],
"must_not": [
{
"exists": {
"field": "location"
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"_name": "Hotel Soller Bay by Ona Hotels"
}
},
{
"term": {
"countryCode.keyword": "ES"
}
},
{
"match": {
"cityName": "Puerto de Soller"
}
}
],
"filter": [
{
"match": {
"type.keyword": "hotel"
}
},
{
"geo_distance": {
"distance": "50m",
"center": {
"lon": 2.689941823,
"lat": 39.79128592
}
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"_name": "Casugria Boutique Residence"
}
},
{
"term": {
"countryCode.keyword": "MY"
}
},
{
"match": {
"cityName": "Malacca "
}
}
],
"filter": [
{
"match": {
"type.keyword": "hotel"
}
},
{
"geo_distance": {
"distance": "50m",
"center": {
"lon": 102.2558338,
"lat": 2.18956804
}
}
}
]
}
}
}
GET niffler_property/_mapping
GET niffler_hotel/_mapping
GET niffler_hotel/_search
{
"from": 1,
"size": 1
}
GET /niffler_property/_count
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "_name"
}
}
]
}
}
}
POST /niffler_property/_update_by_query
{
"script" : "ctx._source.remove('grnConnectId')"
}
GET /niffler_property/_search
{
"size": 0,
"query": {
"bool": {
"must_not": [
{
"term": {
"type.keyword": "hotel"
}
}
]
}
},
"aggs": {
"types": {
"terms": {
"field": "type.keyword",
"size": 13,
"order": {
"_count": "asc"
}
}
}
}
}
GET /grn_hotels/_search
{
"size": 0,
"aggs": {
"countries": {
"terms": {
"field": "country_code.keyword"
},
"aggs": {
"cities": {
"terms": {
"field": "city.keyword"
}
},
"star": {
"terms": {
"field": "star_category"
}
}
}
}
}
}
GET /grn_hotels/_search
{
"size": 0,
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "location"
}
},
{
"term": {
"found": true
}
}
]
}
},
"aggs": {
"countries": {
"terms": {
"field": "country_code.keyword"
},
"aggs": {
"cities": {
"terms": {
"field": "city.keyword"
},
"aggs": {
"star": {
"terms": {
"field": "star_category"
}
}
}
},
"star": {
"terms": {
"field": "star_category"
}
}
}
},
"star": {
"terms": {
"field": "star_category"
},
"aggs": {
"countries": {
"terms": {
"field": "country_code.keyword"
},
"aggs": {
"cities": {
"terms": {
"field": "city.keyword"
}
}
}
}
}
}
}
}
GET /grn_hotels/_search
{
"size": 0,
"aggs": {
"countries": {
"terms": {
"field": "country_code.keyword"
},
"aggs": {
"cities": {
"terms": {
"field": "city.keyword"
},
"aggs": {
"star": {
"terms": {
"field": "star_category"
}
}
}
}
}
}
}
}
GET /niffler_hotel,niffler_property/_search
{
"query": {
"ids": {
"values": [ "H1153858" ]
}
}
}
POST /niffler_property/doc/H267397/_update
{
"doc": {
"grnConnectId": "H!0429170"
}
}
POST /niffler_hotel/doc/H267397/_update
{
"doc": {
"grnConnectId": "H!0429170"
}
}
POST /grn_hotels/doc/H!0429170/_update
{
"doc": {
"found": true
}
}
POST /grn_hotels/doc/H!0429170/_update
{
"doc": {
"found": false
}
}
GET /niffler_property/_count
{
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
GET /grn_hotels/_count
{
"query": {
"term": {
"found": true
}
}
}
POST /niffler_property/_update_by_query
{
"script" : "ctx._source.remove('grnConnectId')",
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
POST /niffler_hotel/_update_by_query
{
"script" : "ctx._source.remove('grnConnectId')",
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
GET /grn_hotels/_count
{
"query": {
"term": {
"found": true
}
}
}
GET /niffler_hotel/_count
{
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
GET /niffler_property/_count
{
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
GET /grn_hotels/_search
{
"size": 10,
"query": {
"bool": {
"must": [
{
"match": {
"name": "Battlefield Bed & Breakfast Inn"
}
},
{
"term": {
"star_category": 3
}
},
{
"term": {
"city.keyword": "Gettysburg"
}
},
{
"term": {
"country_code.keyword": "US"
}
}
]
}
}
}
POST /department/_update_by_query
{
"query": {
"ids": {
"values": [
"1",
"4"
]
}
},
"script": {
"source": "ctx._source.name = ctx._id + ctx._source.name; ctx._source.discount = params.discount",
"lang": "painless",
"params": {
"items": [{
"id": "1",
"name": "random"
}, {
"id": "4",
"name": "lorem"
}]
}
}
}
GET /niffler_hotel,niffler_property/_count
{
"query": {
"bool": {
"must": [
{
"ids": {
"values": [
"H1184640",
"H513984"
]
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
}
}
GET /grn_hotels/_search
{
"query": {
"bool": {
"must": [
{
"ids": {
"values": [
"H!0215942",
"H!0175089"
]
}
},
{
"term": {
"found": true
}
}
]
}
}
}
POST /department/_update_by_query
{
"query": {
"ids": {
"values": [
"1",
"4"
]
}
},
"script": {
"source": """
for (int i = 0; i < params.items.length; ++i) {
if (params.items[i].id == ctx._id) {
ctx._source.name = params.items[i].name;
break;
}
}
""",
"lang": "painless",
"params": {
"items": [{
"id": "1",
"name": "random"
}, {
"id": "4",
"name": "lorem"
}]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"_name": {
"query": "Battlefield Bed & Breakfast Inn",
"operator": "and"
}
}
},
{
"term": {
"countryCode.keyword": "US"
}
},
{
"match": {
"cityName": {
"query": "Aspers",
"operator": "and"
}
}
}
],
"must_not": [
{
"exists": {
"field": "grnConnectId"
}
}
],
"filter": [
{
"term": {
"type.keyword": "hotel"
}
},
{
"geo_distance": {
"distance": "854.7m",
"center": {
"lon": -77.27018,
"lat": 39.77449
}
}
}
]
}
},
"script_fields": {
"distance": {
"script": {
"lang": "painless",
"source": "doc['center'].arcDistance(params.lat, params.lon)",
"params": {
"lon": -77.27018,
"lat": 39.77449
}
}
}
}
}
GET /niffler_hotel/_count
{
"query": {
"bool": {
"should": [
{
"exists": {
"field": "continent"
}
},
{
"exists": {
"field": "railway_station"
}
},
{
"exists": {
"field": "bus_station"
}
},
{
"exists": {
"field": "country"
}
},
{
"exists": {
"field": "street"
}
},
{
"exists": {
"field": "province"
}
},
{
"exists": {
"field": "multi_region"
}
},
{
"exists": {
"field": "multi_city"
}
},
{
"exists": {
"field": "subway"
}
},
{
"exists": {
"field": "airport"
}
},
{
"exists": {
"field": "neighborhood"
}
},
{
"exists": {
"field": "city"
}
},
{
"exists": {
"field": "point_of_interest"
}
}
]
}
}
}
GET /niffler_property/_delete_by_query
{
"query": {
"bool": {
"must_not": [
{
"term": {
"type.keyword": "hotel"
}
}
]
}
}
}
GET /grn_hotels/_search
{
"query": {
"term": {
"found": false
}
},
"size": 0,
"aggs": {
"cities": {
"terms": {
"field": "city.keyword",
"show_term_doc_count_error": true,
"order": {
"_count": "asc"
},
"size": 100
}
}
}
}
GET /grn_hotels/_search
{
"query": {
"term": {
"found": false
}
},
"size": 0,
"aggs": {
"cities": {
"terms": {
"field": "city.keyword",
"show_term_doc_count_error": true,
"order": {
"_count": "asc"
},
"size": 100
}
}
}
}
POST /grn_hotels/_update_by_query
{
"query": {
"ids": {
"values": [
"H!0215942",
"H!0175089"
]
}
},
"script": {
"source": "ctx._source.found = false"
}
}
POST /niffler_hotel,niffler_property/_update_by_query
{
"query": {
"ids": {
"values": [
"H1184640",
"H513984"
]
}
},
"script": {
"source": "ctx._source.remove('grnConnectId')"
}
}
GET /niffler_property/_search
{
"stored_fields": "_source",
"query": {
"bool": {
"must": [
{
"match": {
"_name": {
"query": "Premier Inn Hereford",
"operator": "or"
}
}
},
{
"term": {
"countryCode.keyword": "GB"
}
}
],
"should": [
{
"match": {
"cityName": {
"query": "Hereford",
"operator": "or"
}
}
}
],
"filter": [
{
"term": {
"type.keyword": "hotel"
}
},
{
"geo_distance": {
"center": {
"lat": 52.074247,
"lon": -2.722485
},
"distance": "1000m"
}
}
],
"must_not": {
"exists": {
"field": "grnConnectId"
}
}
}
},
"size": "2",
"script_fields": {
"distance": {
"script": {
"source": "doc['center'].arcDistance(params.lat, params.lon)",
"params": {
"lat": 52.074247,
"lon": -2.722485
}
}
}
}
}
//////////////////////reset mapped ids//////////////////
POST /grn_hotels/_update_by_query
{
"query": {
"ids": {
"values": [
"H!0215942",
"H!0175089"
]
}
},
"script": {
"source": "ctx._source.found = false"
}
}
POST /niffler_hotel,niffler_property/_update_by_query
{
"query": {
"ids": {
"values": [
"H1184640",
"H513984"
]
}
},
"script": {
"source": "ctx._source.remove('grnConnectId')"
}
}
//////////////////////reset mapped ids//////////////////
////////////////////////sample search query//////////////
GET /niffler_property/_search
{
"stored_fields": "_source",
"query": {
"bool": {
"must": [
{
"match": {
"_name": {
"query": "Premier Inn Hereford",
"operator": "or"
}
}
},
{
"term": {
"countryCode.keyword": "GB"
}
}
],
"should": [
{
"match": {
"cityName": {
"query": "Hereford",
"operator": "or"
}
}
}
],
"filter": [
{
"term": {
"type.keyword": "hotel"
}
},
{
"geo_distance": {
"center": {
"lat": 52.074247,
"lon": -2.722485
},
"distance": "1000m"
}
}
],
"must_not": {
"exists": {
"field": "grnConnectId"
}
}
}
},
"size": "2",
"script_fields": {
"distance": {
"script": {
"source": "doc['center'].arcDistance(params.lat, params.lon)",
"params": {
"lat": 52.074247,
"lon": -2.722485
}
}
}
}
}
//////////////////////////////////////////////////////
//////////////////////search ids////////////////////////
GET /grn_hotels/_search?filter_path=hits.hits.*,aggregations.*
{
"_source": {
"excludes": [
"description",
"address",
"postal_code",
"found"
]
},
"query": {
"bool": {
"must": [
{
"ids": {
"values": [
"H!0215942",
"H!0175089"
]
}
},
{
"term": {
"found": true
}
}
]
}
}
}
GET /niffler_hotel,niffler_property/_search?filter_path=hits.hits.*,aggregations.*
{
"_source": {
"includes": [
"starRating",
"_name",
"center",
"cityName",
"countryCode",
"grnConnectId"
]
},
"query": {
"bool": {
"must": [
{
"ids": {
"values": [
"H1184640",
"H513984"
]
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
}
}
////////////////////////////////////////////////////////////////////
GET /niffler_property/_search
{
"query": {
"exists": {
"field": "grnConnectId"
}
}
}
GET /niffler_property/_search
{
"size": 0,
"query": {
"bool": {
"must_not": [
{
"term": {
"type.keyword": "hotel"
}
}
]
}
},
"aggs": {
"types": {
"terms": {
"field": "type.keyword",
"size": 13,
"order": {
"_count": "asc"
}
}
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits._source
{
"query": {
"bool": {
"must": [
{
"term": {
"city.id.keyword": "R602651"
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
},
"size": 10000
}
GET /niffler_hotel/_search?filter_path=hits.hits._source
{
"size": 10000,
"_source": {
"includes": "grnConnectId"
},
"query": {
"bool": {
"must": [
{
"term": {
"city.id.keyword": "R602651"
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": "hotel"
}
},
{
"match": {
"_name": "Test Hotel (Do Not Book)"
}
},
{
"term": {
"cityName.keyword": "Belogorsk"
}
},
{
"term": {
"countryCode.keyword": "RU"
}
}
]
}
},
"from": 0
}
GET /niffler_hotel/_search?filter_path=hits.hits._id%2Chits.hits._source
{
"query": {
"ids": {
"values": [
"H984506",
"H733539",
"H1259427",
"H734419",
"H784139"
]
}
}
}
GET /grn_hotels/_count
{
"query": {
"bool": {
"must": [
{
"term": {
"found": {
"value": true
}
}
}
]
}
}
}
GET /niffler_property/_count
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "grnConnectId"
}
}
]
}
}
}
GET /grn_hotels/_count
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "found"
}
}
]
}
}
}
GET /niffler_property/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "grnConnectId"
}
},
{
"term": {
"isSearchable": true
}
}
]
}
},
"aggs": {
"based_by_cities": {
"terms": {
"field": "cityName.keyword",
"size": 10
}
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": "city"
}
},
{
"match": {
"name": "Rome"
}
},
{
"term": {
"countryCode.keyword": "IT"
}
}
]
}
}
}
GET /niffler_property/_search?_source=false&filter_path=hits.hits._id
{
"query": {
"term": {
"grnConnectId.keyword": "H!0161741"
}
}
}
HEAD /available_hotels_g4fwa40kapajs6f/_doc/H417305
GET /available_hotels_g4fwa40kapajs6f/_settings
GET /_ilm/policy
GET /niffler_hotel/_search?_source=roomGroups&filter_path=hits.hits.*.roomGroups,hits.hits._id
{
"size": 65,
"query": {
"bool": {
"must": [
{
"range": {
"starRating": {
"gte": 5
}
}
},
{
"term": {
"country.name.keyword": "Italy"
}
},
{
"term": {
"city.name.keyword": "Rome"
}
},
{
"exists": {
"field": "grnConnectId"
}
},
{
"exists": {
"field": "roomGroups"
}
}
]
}
}
}
GET /niffler_hotel/_search?_source=roomGroups&filter_path=hits.hits.*.roomGroups,hits.hits._id
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "roomGroups"
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"term": {
"grnConnectId.keyword": {
"value": "H!0024184"
}
}
}
}
GET /_nodes
GET /_nodes/stats
GET /available_hotels_1667o8apqkaz47y7n/_search
{
"query": {
"range": {
"hotel.starRating": {
"gte": 5
}
}
}
}
GET /niffler_hotel/_search?_source=roomGroups&filter_path=hits.hits.*.roomGroups
{
"size": 2,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
},
{
"range": {
"starRating": {
"lte": 1
}
}
}
]
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits.*.roomGroups
{
"_source": {
"includes": ["roomGroups.roomAmenities", "amenityGroups.amenities"]
},
"size": 1,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
},
{
"range": {
"starRating": {
"lte": 1
}
}
}
]
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits.*.roomGroups,hits.hits.*.amenityGroups
{
"_source": {
"includes": ["roomGroups.roomAmenities", "amenityGroups"]
},
"size": 1,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
}
]
}
}
}
GET /niffler_hotel/_count
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
}
],
"must_not": [
{
"exists": {
"field": "amenityLogo"
}
}
]
}
}
}
GET /niffler_hotel/_search
{
"size": 1,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
},
{
"range": {
"starRating": {
"lte": 1
}
}
}
]
}
}
}
GET /niffler_hotel/_search?filter_path=_scroll_id,hits.hits.*.roomGroups,hits.hits.*.amenityGroups&scroll=5m
{
"size": 1,
"_source": {
"includes": ["roomGroups.roomAmenities", "amenityGroups"]
},
"query": {
"bool": {
"should": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
},
{
"exists": {
"field": "amenityGroups.amenities"
}
}
],
"minimum_should_match": 1
}
}
}
GET /_search/scroll?filter_path=_scroll_id,hits.hits.*.roomGroups,hits.hits.*.amenityGroups
{
"scroll" : "5m",
"scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi7-FlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvARZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLv8WUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi8AFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvAhZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR"
}
GET /_nodes/stats/indices/search
DELETE /_search/scroll/_all
DELETE /_search/scroll
{
"scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi94FlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYveRZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGL3sWUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi96FlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvfBZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR"
}
DELETE /_search/scroll
{
"scroll_id" : [
"DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi3wFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYt8RZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLfIWUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi3zFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYt9BZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR"
]
}
DELETE /_search/scroll/DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi7lFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYu5hZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLucWUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi7oFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYu6RZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR,DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi7yFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYu8xZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLvQWUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi71FlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYu9hZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR
DELETE /_search/scroll?scroll_id=DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi7-FlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvARZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLv8WUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi8AFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvAhZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR,DnF1ZXJ5VGhlbkZldGNoBQAAAAAABi8MFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvDxZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGLw0WUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABi8OFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAYvEBZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR
GET /niffler_hotel/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
}
]
}
},
"aggs": {
"roomAmenities": {
"terms": {
"field": "roomGroups.roomAmenities.keyword",
"min_doc_count": 1,
"size": 100
}
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits.*.roomGroups
{
"_source": {
"includes": "roomGroups.roomAmenities"
},
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
},
{
"term": {
"starRating": 5
}
},
{
"ids": {"values": ["H976568", "H306929"]}
}
]
}
}
}
GET /_search/scroll
{
"scroll" : "1m",
"scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAABj4oFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAY-KhZRcUxVelJuOVFrU2hYU2JUV1ZpQmRRAAAAAAAGPisWUXFMVXpSbjlRa1NoWFNiVFdWaUJkUQAAAAAABj4sFlFxTFV6Um45UWtTaFhTYlRXVmlCZFEAAAAAAAY-KRZRcUxVelJuOVFrU2hYU2JUV1ZpQmRR"
}
GET /niffler_hotel/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
}
]
}
},
"aggs": {
"amenityGroupsGroupNames": {
"terms": {
"field": "amenityGroups.groupName.keyword",
"min_doc_count": 1,
"size": 100
},
"aggs": {
"amenities": {
"terms": {
"field": "amenityGroups.amenities.keyword",
"size": 1000,
"min_doc_count": 1
}
}
}
}
}
}
GET /niffler_hotel/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
}
]
}
},
"aggs": {
"amenityGroupsGroupNames": {
"terms": {
"field": "amenityGroups.groupName.keyword",
"min_doc_count": 1,
"size": 100
}
}
}
}
GET /niffler_hotel/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "roomGroups.roomAmenities"
}
}
],
"must_not": [
{
"terms": {
"roomGroups.roomAmenities.keyword": [
"private-bathroom",
"shower",
"window",
"tv",
"hairdryer",
"air-conditioning",
"toiletries",
"wardrobe",
"towels",
"balcony",
"with-view",
"safe",
"bath",
"mini-bar",
"accessible",
"bathrobe",
"terrace",
"shared-bathroom",
"sofa",
"kitchen",
"barbecue",
"fridge",
"tea",
"iron",
"kitchen-stuff",
"washing-machine",
"microwave",
"blackout-blinds",
"extra-bed",
"mirror",
"telephone",
"jacuzzi",
"water",
"soundproofing",
"child-cot",
"tea-or-coffee",
"hypoallergenic",
"addon-service",
"no-window",
"pool",
"wi-fi",
"bridal",
"fireplace",
"sauna",
"spa-access",
"external-private-bathroom",
"attic",
"pillows",
"twin",
"transfer",
"beach-access",
"present",
"beach",
"double",
"lounge",
"bunk-bed",
"coffee",
"golf",
"aquapark",
"beachfront",
"dishwasher",
"non-smoking",
"wired-internet-access"
]
}
}
]
}
}
}
GET /niffler_hotel/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
}
],
"must_not": [
{
"terms": {
"amenityGroups.groupName.keyword": [
"General",
"Rooms",
"Meals",
"Room Amenities",
"Internet",
"Pool and beach",
"Pets",
"Kids",
"Languages Spoken",
"Accessibility",
"Recreation",
"Parking",
"Tourist services",
"Business",
"Sports",
"Beauty and wellness",
"Transfer",
"Winter sports",
"Business "
]
}
}
]
}
}
}
GET /niffler_hotel/_search?filter_path=aggregations.amenities.buckets.key
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
},
{
"terms": {
"amenityGroups.groupName.keyword": [
"Internet"
]
}
}
]
}
},
"aggs": {
"amenities": {
"terms": {
"field": "amenityGroups.amenities.keyword",
"size": 1000,
"min_doc_count": 1
}
}
}
}
GET /niffler_hotel/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "amenityGroups.amenities"
}
},
{
"nested": {
"path": "amenityGroups",
"query": {
"bool": {
"must": [
{
"term": {
"amenityGroups.groupName.keyword": "General"
}
}
],
"must_not": [
{
"terms": {
"amenityGroups.amenities.keyword": [
"TV",
"Air conditioning",
"Shower",
"Wi-Fi",
"Non-smoking rooms",
"Heating",
"Luggage storage",
"Terrace",
"English",
"Shower/Bathtub",
"Laundry",
"Garden",
"Pets Not Allowed",
"Fridge",
"Beach/pool towels",
"Cable TV",
"Restaurant",
"Room service",
"Family/Kid Friendly",
"Safe-deposit box",
"Iron and board",
"Elevator/lift",
"Bar",
"Wardrobe/Closet",
"All Spaces Non-Smoking (public and private)",
"Breakfast",
"Telephone",
"Internet access",
"Tour assistance",
"Parking",
"Wake-up service",
"Hairdryer",
"Microwave oven",
"Swimming pool",
"Newspapers",
"Iron",
"Linens",
"Outdoor pool",
"Bathtub",
"Accessibility features",
"In-room internet",
"Slippers",
"Smoke-free property",
"Bike rental",
"Kitchen",
"Dry-cleaning",
"Car rental",
"Outdoor furniture",
"Business center",
"Ironing",
"Sun Deck",
"Barbecue grill(s)",
"Minibar",
"Express check-in/check-out",
"Breakfast in the room",
"Massage",
"Washing machine",
"Event facilities",
"Soundproof rooms",
"French",
"Patio",
"Fax and copy machine",
"Smoking allowed in bedrooms",
"Spanish",
"Safe (in room)",
"Airport transportation",
"Spa",
"German",
"Conference Hall",
"Meeting and presentation facilities",
"Hiking",
"Next to the beach",
"Bottled water",
"Italian",
"Coffeemaker",
"Fitness facilities",
"Shopping on site",
"Cycling",
"Private check-in/check-out",
"Multi-language staff",
"Concierge services",
"Sauna",
"Bathrobe",
"DVD Player",
"Cafe",
"Alarm clock",
"Radio",
"Reception desk",
"Fishing",
"Currency exchange",
"Library",
"Free Parking on Premises",
"Beach facilities",
"Picnic area",
"Diet menu (on request)",
"Packed Lunches",
"Babysitting and childcare",
"Gift shop",
"24-hour reception",
"Gym",
"Golf course",
"Spa tub",
"Dishwasher",
"Playroom",
"Beauty services",
"Coffee/tea for guests",
"Children's playground",
"Tennis court",
"Vending machine",
"Indoor Fireplace",
"Poolside bar",
"Barbeque",
"Bridal suite",
"Skiing",
"Seasonal outdoor swimming pool",
"Indoor Pool",
"Russian",
"Television in lobby",
"Kids' TV Networks",
"Pets allowed",
"Shoe shine",
"Ticket assistance",
"Table Tennis",
"Mosquito net",
"ATM",
"Hairdryer (on request)",
"Kitchenette",
"Free parking nearby",
"Transfer services",
"Security guard",
"Upper floors accessible by elevator",
"Children swimming pool",
"Steam room",
"Ping-Pong",
"Diving",
"Clothes rack",
"No elevators",
"Ski storage",
"Locker",
"Offsite parking reservations required",
"Solarium",
"Private beach",
"Dryer",
"Portuguese",
"VIP room amenities",
"Billiards",
"Karaoke",
"Darts",
"Kids club",
"Shuttle",
"Allergy-free rooms",
"Snack bar",
"Bowling",
"Children's menu",
"Polish",
"Nightclub",
"Mini golf",
"Chapel",
"Heated swimming pool",
"Adults Only",
"Doorman",
"Health club",
"Area shuttle",
"Parking nearby",
"Baby sleepers",
"Early check-in",
"Smoking areas",
"Late check-out",
"Laptop safe",
"Free Wi-Fi",
"24 - hour gym",
"Common kitchen",
"Hammam",
"Japanese",
"Casino",
"Horse riding",
"Ski-to-Door Access",
"Snorkelling",
"Bottled water (at extra charge)",
"Express check-in",
"Squash",
"Water sport facilities",
"Free shuttle",
"Mini-fridge",
"Fax machine",
"Skiing Off-site",
"Computer",
"Train station shuttle",
"Yoga",
"Windsurfing",
"Fire Extinguisher",
"Free parking",
"Area shuttle (complimentary)",
"Pets allowed (under 5 kg)",
"Korean",
"Sailing",
"Wi-Fi in the hotel",
"Photocopy machines",
"Trouser press",
"Water park",
"Doctor on call",
"Indoor heated swimming pool",
"Shopping center shuttle",
"Breakfast/lunch to go",
"Ski school",
"Port shuttle",
"Wheelchair access to restaurant",
"Pets allowed (free)",
"Ski shuttle",
"First Aid Kit",
"Suitable for Events",
"Wheelchair access to bar",
"Seasonal indoor swimming pool",
"Design hotel",
"Entertainment",
"Baths",
"Toilets with grab bars",
"Boating",
"Water fun",
"Full board rates available",
"Outdoor heated swimming pool",
"Half board rates available",
"Pharmacy",
"Shopping center shuttle (complimentary)",
"Beach shuttle",
"Beach shuttle (complimentary)",
"Smoking Allowed",
"Pool facilities",
"Deposit boxes",
"Free train station shuttle",
"Bank",
"Casino shuttle",
"Internet",
"Theatre",
"Restaurant (buffet style)",
"Doctor",
"Free bicycle rental",
"Ski facilities rental",
"Pets not allowed (over 5 kg)",
"Pets not allowed (under 5 kg)",
"Free internet",
"Badminton",
"Ice skating",
"Rental video equipment and computers",
"Buffet breakfast",
"Museum",
"Snowmobile and quad bikes rental",
"No parking",
"Bathrobe (on request)",
"Golf сourse (within 3 km)",
"Airport transportation (complimentary)",
"Hunt",
"Winery",
"Airport transportation - drop-off",
"Airport transportation - pickup",
"Express check-out",
"Yachting",
"Snowboard",
"Heated children swimming pool",
"Ski passes available",
"Taxi booking",
"Flat-screen TV",
"Music system",
"Pets allowed (under 5 kg) (surcharge)",
"Airport transportation - drop-off (complimentary)",
"Buzzer/Wireless Intercom",
"Massage (at extra charge)",
"Pets Allowed",
"Pets allowed (over 5 kg)",
"Port shuttle (complimentary)",
"Privat check-in/check-out",
"Airport transportation (surcharge)",
"Casino shuttle (complimentary)",
"Children's menu (at extra charge)",
"Newspapers ",
"Pets Allowed (Surcharge)",
"Transfer to the beach",
"Garage",
"Ironing accessories (by request)",
"Shuttle (surcharge)",
"Transfer to the beach (free)"
]
}
}
]
}
}
}
}
]
}
}
}
DELETE /drivers
PUT /drivers
{
"mappings": {
"_doc": {
"properties": {
"driver": {
"type": "nested",
"properties": {
"last_name": {
"type": "text"
},
"vehicle": {
"type": "nested",
"properties": {
"make": {
"type": "text"
},
"model": {
"type": "text"
}
}
}
}
}
}
}
}
}
PUT /drivers/_doc/1
{
"driver": {
"last_name": "McQueen",
"vehicle": [
{
"make": "Powell Motors",
"model": "Canyonero"
},
{
"make": "Miller-Meteor",
"model": "Ecto-1"
}
]
}
}
PUT /drivers/_doc/2?refresh
{
"driver": {
"last_name": "Hudson",
"vehicle": [
{
"make": "Mifune",
"model": "Mach Five"
},
{
"make": "Miller-Meteor",
"model": "Ecto-1"
}
]
}
}
GET /drivers/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "driver",
"query": {
"nested": {
"path": "driver.vehicle",
"query": {
"bool": {
"must": [
{
"match": {
"driver.vehicle.make": "Powell Motors"
}
},
{
"match": {
"driver.vehicle.model": "Canyonero"
}
}
]
}
}
}
}
}
},
{
"ids": {
"values": ["1"]
}
}
]
}
}
}
GET /drivers/_mapping
GET /drivers/_mapping/field/*
GET /drivers/_mapping/field/driver*
PUT /drivers
{
"mappings": {
"_doc": {
"properties": {
"vehicle": {
"type": "nested",
"properties": {
"make": {
"type": "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"model": {
"type": "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
PUT /drivers/_doc/1
{
"vehicle": [
{
"make": "Powell Motors",
"model": "Canyonero"
},
{
"make": "Miller-Meteor",
"model": "Ecto-1"
}
]
}
PUT /drivers/_doc/2?refresh
{
"vehicle": [
{
"make": "Mifune",
"model": "Mach Five"
},
{
"make": "Miller-Meteor",
"model": "Ecto-1"
}
]
}
GET /drivers/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "vehicle",
"query": {
"bool": {
"must": [
{
"match": {
"vehicle.make": "Mifune"
}
},
{
"match": {
"vehicle.model": "Mach Five"
}
},
{
"term": {
"vehicle.make.keyword": "Mifune"
}
}
]
}
}
}
}
]
}
}
}
GET /niffler_hotel/_mapping/field/amenityGroups.groupName
GET /niffler_hotel/_mapping/
GET /drivers/_search
{
"aggs": {
"makes": {
"terms": {
"field": "vehicle.make.keyword"
},
"aggs": {
"models": {
"terms": {
"field": "vehicle.model.keyword"
}
}
}
}
}
}
GET /drivers/_search
{
"aggs": {
"makes": {
"nested": {
"path": "vehicle"
},
"aggs": {
"makes": {
"terms": {
"field": "vehicle.make.keyword"
},
"aggs": {
"models": {
"terms": {
"field": "vehicle.model.keyword"
}
}
}
}
}
}
}
}
# When I search for list of hotels for GRN with city
GET /niffler_hotel/_search?filter_path=hits.hits._source.grnConnectId
{
"query": {
"bool": {
"must": [
{
"term": {
"city.id.keyword": "R602651"
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
},
"size": 10000,
"_source": "grnConnectId"
}
GET /niffler_property/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"exists": {
"field": "grnConnectId"
}
},
{
"term": {
"isSearchable": true
}
}
]
}
},
"aggs": {
"based_by_cities": {
"terms": {
"field": "cityName.keyword",
"size": 10
}
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "grnConnectId"
}
},
{
"term": {
"cityName.keyword": "Bali"
}
},
{
"term": {
"countryCode.keyword": "ID"
}
},
{
"term": {
"isSearchable": true
}
}
]
}
}
}
# When I search for list of hotels for GRN with city
GET /niffler_hotel/_search?filter_path=hits.hits._source.grnConnectId
{
"query": {
"bool": {
"must": [
{
"term": {
"city.id.keyword": "R602651"
}
},
{
"exists": {
"field": "grnConnectId"
}
}
]
}
},
"size": 10000,
"_source": "grnConnectId"
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "grnConnectId"
}
},
{
"exists": {
"field": "timezone"
}
},
{
"term": {
"type.keyword": "hotel"
}
}
]
}
}
}
GET /grn_hotels/_search?filter_path=hits.hits._id
{
"size": 1,
"_source": false,
"query": {
"term": {
"found": false
}
},
"from": 0
}
# H1295576
GET /niffler_hotel/_search?filter_path=hits.hits._id
{
"size": 10000,
"_source": false,
"sort": [
{
"id": "asc"
}
],
"query": {
"regexp": {
"id": "H1[1-2]955[0-9]{2}"
}
}
}
GET /niffler_property/_search?filter_path=hits.hits._id
{
"size": 10000,
"_source": false,
"sort": [
{
"id": "desc"
}
],
"query": {
"regexp": {
"id": "H1[2]955[0-9]{2}"
}
}
}
GET /niffler_hotel/_count
{
"query": {
"regexp": {
"id": "H1[2]955[0-9]{2}"
}
}
}
# search city
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"fullAddress": "Dhak"
}
},
{
"term": {
"type.keyword": "city"
}
}
]
}
}
}
# get unique types aggregation
GET /niffler_property/_search
{
"size": 0,
"aggs": {
"types": {
"terms": {
"field": "type.keyword",
"min_doc_count": 1,
"size": 10000
}
}
}
}
GET /grn_hotels/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"country_code.keyword": "ID"
}
},
{
"term": {
"found": true
}
},
{
"term": {
"city.keyword": "Uluwatu"
}
}
]
}
}
}
GET /niffler_property/_search?filter_path=hits.hits._source.countryName
{
"size": 1,
"query": {
"bool": {
"must": [
{
"term": {
"countryCode.keyword": "CN"
}
}
]
}
},
"_source": "countryName"
}
GET /grn_hotels/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "images"
}
}
]
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits._id,hits.hits._source
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "checkInTime"
}
}
]
}
},
"size": 1,
"_source": "checkInTime"
}
GET /niffler_hotel/_search?filter_path=hits.hits._id,hits.hits._source
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "checkInTime"
}
}
]
}
},
"size": 1,
"_source": "checkInTime"
}
PUT /test/_doc/1
{
"name": "Test",
"facilities": [
"Air conditioning"
]
}
GET /test/_search
{
"size": 0,
"aggs": {
"facilities": {
"terms": {
"field": "facilities.keyword",
"size": 1000
}
}
}
}
GET /niffler_hotel/_search?filter_path=hits.hits._id,hits.hits._source
{
"query": {
"bool": {
"should": [
{
"exists": {
"field": "airport"
}
},
{
"exists": {
"field": "amenityGroups"
}
},
{
"exists": {
"field": "amenityLogo"
}
},
{
"exists": {
"field": "bus_station"
}
},
{
"exists": {
"field": "checkInTime"
}
},
{
"exists": {
"field": "checkOutTime"
}
},
{
"exists": {
"field": "city"
}
},
{
"exists": {
"field": "contact"
}
},
{
"exists": {
"field": "country"
}
},
{
"exists": {
"field": "descriptionStruct"
}
},
{
"exists": {
"field": "featured"
}
},
{
"exists": {
"field": "grnConnectId"
}
},
{
"exists": {
"field": "id"
}
},
{
"exists": {
"field": "images"
}
},
{
"exists": {
"field": "kind"
}
},
{
"exists": {
"field": "multi_city"
}
},
{
"exists": {
"field": "multi_region"
}
},
{
"exists": {
"field": "name"
}
},
{
"exists": {
"field": "neighborhood"
}
},
{
"exists": {
"field": "point_of_interest"
}
},
{
"exists": {
"field": "policyStruct"
}
},
{
"exists": {
"field": "province"
}
},
{
"exists": {
"field": "railway_station"
}
},
{
"exists": {
"field": "rateHawkId"
}
},
{
"exists": {
"field": "rating"
}
},
{
"exists": {
"field": "reviews"
}
},
{
"exists": {
"field": "roomGroups"
}
},
{
"exists": {
"field": "semanticVersion"
}
},
{
"exists": {
"field": "starRating"
}
},
{
"exists": {
"field": "street"
}
},
{
"exists": {
"field": "subway"
}
},
{
"exists": {
"field": "thumbnail"
}
}
],
"minimum_should_match": 30
}
},
"size": 1,
"from": 0
}
GET /niffler_hotel/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "province"
}
}
],
"should": [
{
"exists": {
"field": "airport"
}
},
{
"exists": {
"field": "amenityGroups"
}
},
{
"exists": {
"field": "amenityLogo"
}
},
{
"exists": {
"field": "bus_station"
}
},
{
"exists": {
"field": "checkInTime"
}
},
{
"exists": {
"field": "checkOutTime"
}
},
{
"exists": {
"field": "city"
}
},
{
"exists": {
"field": "contact"
}
},
{
"exists": {
"field": "country"
}
},
{
"exists": {
"field": "descriptionStruct"
}
},
{
"exists": {
"field": "featured"
}
},
{
"exists": {
"field": "grnConnectId"
}
},
{
"exists": {
"field": "id"
}
},
{
"exists": {
"field": "images"
}
},
{
"exists": {
"field": "kind"
}
},
{
"exists": {
"field": "multi_city"
}
},
{
"exists": {
"field": "multi_region"
}
},
{
"exists": {
"field": "name"
}
},
{
"exists": {
"field": "neighborhood"
}
},
{
"exists": {
"field": "point_of_interest"
}
},
{
"exists": {
"field": "policyStruct"
}
},
{
"exists": {
"field": "province"
}
},
{
"exists": {
"field": "railway_station"
}
},
{
"exists": {
"field": "rateHawkId"
}
},
{
"exists": {
"field": "rating"
}
},
{
"exists": {
"field": "reviews"
}
},
{
"exists": {
"field": "roomGroups"
}
},
{
"exists": {
"field": "semanticVersion"
}
},
{
"exists": {
"field": "starRating"
}
},
{
"exists": {
"field": "street"
}
},
{
"exists": {
"field": "subway"
}
},
{
"exists": {
"field": "thumbnail"
}
}
],
"minimum_should_match": 30
}
},
"size": 1
}
# Search cities that in BD & parent R15 & prefix comilla size 1
# Remove parentId & find the city if exist
# If not exist search a hotel that is within a range then use that for city & country
GET /niffler_property/_search
{
"size": 1,
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"fullAddress": "Comilla"
}
},
{
"term": {
"type.keyword": {
"value": "city"
}
}
},
{
"term": {
"countryCode.keyword": {
"value": "BD"
}
}
},
{
"term": {
"parentId": {
"value": "R15"
}
}
}
]
}
}
}
# city most less fields
GET /niffler_property/_search
{
"size": 1,
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": {
"value": "city"
}
}
}
],
"should": [
{
"bool": {
"must_not": [
{
"exists": {
"field": "_name"
}
},
{
"exists": {
"field": "airport"
}
},
{
"exists": {
"field": "alias"
}
},
{
"exists": {
"field": "bus_station"
}
},
{
"exists": {
"field": "center"
}
},
{
"exists": {
"field": "city"
}
},
{
"exists": {
"field": "cityName"
}
},
{
"exists": {
"field": "country"
}
},
{
"exists": {
"field": "countryCode"
}
},
{
"exists": {
"field": "countryName"
}
},
{
"exists": {
"field": "featured"
}
},
{
"exists": {
"field": "fullAddress"
}
},
{
"exists": {
"field": "grnConnectId"
}
},
{
"exists": {
"field": "hotelsCount"
}
},
{
"exists": {
"field": "id"
}
},
{
"exists": {
"field": "isSearchable"
}
},
{
"exists": {
"field": "multi_city"
}
},
{
"exists": {
"field": "multi_region"
}
},
{
"exists": {
"field": "name"
}
},
{
"exists": {
"field": "neighborhood"
}
},
{
"exists": {
"field": "neighborhoods"
}
},
{
"exists": {
"field": "parentId"
}
},
{
"exists": {
"field": "point_of_interest"
}
},
{
"exists": {
"field": "province"
}
},
{
"exists": {
"field": "query"
}
},
{
"exists": {
"field": "railway_station"
}
},
{
"exists": {
"field": "rateHawkId"
}
},
{
"exists": {
"field": "street"
}
},
{
"exists": {
"field": "subway"
}
},
{
"exists": {
"field": "timezone"
}
},
{
"exists": {
"field": "type"
}
},
{
"exists": {
"field": "userHits"
}
}
]
}
}
]
}
}
}
GET /niffler_property/_search
{
"query": {
"bool": {
"must": [
{
"regexp": {
"countryCode.keyword": "[A-Z]*[A-Z]*"
}
}
]
}
}
}
GET /grn_hotels/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "location"
}
},
{
"term": {
"country_code.keyword": {
"value": "ID"
}
}
},
{
"term": {
"city.keyword": {
"value": "Kuta , Bali"
}
}
}
]
}
}
}
GET /niffler_property/_search
{
"size": 1,
"stored_fields": "_source",
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": "city"
}
},
{
"term": {
"countryCode.keyword": "ID"
}
}
],
"should": [
{
"match": {
"name": {
"query": "Bali",
"operator": "or"
}
}
}
]
}
},
"script_fields": {
"distance": {
"script": {
"source": "doc['center'].arcDistance(params.lat, params.lon)",
"params": {
"lat": -8.713361979,
"lon": 115.1705635
}
}
}
},
"sort": [
{
"_score": "desc"
},
{
"_script": {
"type": "number",
"script": {
"lang": "painless",
"source": "doc['center'].arcDistance(params.lat, params.lon)",
"params": {
"lat": -8.713361979,
"lon": 115.1705635
}
},
"order": "asc"
}
}
]
}
# Get scripts all
GET _cluster/state/metadata?pretty&filter_path=**.stored_scripts
# Get a specific script
GET _cluster/state/metadata?pretty&filter_path=**.stored_scripts.add-image-to-grn-hotel-index
# GET cities by countryCode & get unique parentId
GET /niffler_property/_search?filter_path=hits.hits._id,hits.hits._source,hits.hits._source,aggregations
{
"size": 30,
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": {
"value": "city"
}
}
},
{
"term": {
"countryCode.keyword": {
"value": "BD"
}
}
}
]
}
},
"_source": ["name"],
"aggs": {
"parentIds": {
"terms": {
"field": "parentId",
"size": 10000,
"min_doc_count": 1
}
}
}
}
# GET hotels by countryCode & show hotel count by city
GET /niffler_property/_search?filter_path=aggregations.cities.buckets
{
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"type.keyword": {
"value": "hotel"
}
}
},
{
"term": {
"countryCode.keyword": {
"value": "BD"
}
}
}
]
}
},
"aggs": {
"cities": {
"terms": {
"field": "cityName.keyword",
"size": 10000,
"min_doc_count": 1
}
}
}
}
# GET index field mapping
GET /niffler_property/_mapping/doc/field/stHotelId?include_type_name=true
# ADD stHotelId mapping to niffler_property
PUT /niffler_property/doc/_mapping
{
"properties": {
"stHotelId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
# GET hotels from city & get unique city ids
GET /niffler_hotel/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"city.id.keyword": "R601928"
}
},
{
"exists": {
"field": "rateHawkId"
}
}
]
}
},
"size": 0,
"aggs": {
"cities": {
"terms": {
"field": "city.id.keyword",
"size": 10000,
"min_doc_count": 1
}
}
}
}
# GRN hotel contacts count
GET /grn_hotels/_count
{
"query": {
"bool": {
"should": [
{
"exists": {
"field": "phone"
}
},
{
"exists": {
"field": "fax"
}
},
{
"exists": {
"field": "url"
}
},
{
"exists": {
"field": "email"
}
}
],
"minimum_should_match": 1
}
}
}
# GRN hotel count images
GET /grn_hotels/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "images",
"query": {
"bool": {
"must": [
{
"exists": {
"field": "images"
}
}
]
}
}
}
}
]
}
},
"_source": "images",
"aggs": {
"images": {
"nested": {
"path": "images"
},
"aggs": {
"image_url_count": {
"value_count": {
"field": "images.url.keyword"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment