Created
July 21, 2020 16:45
-
-
Save emanuil-tolev/0b6de4429fbe769e77a80ea50e33ac27 to your computer and use it in GitHub Desktop.
Elasticsearch demo scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET / | |
#### 1ST PART CRUD | |
DELETE villas | |
# Create the first doc | |
PUT villas/_doc/yorkshire | |
{ | |
"message": "This is Yorkshire" | |
} | |
GET villas/_doc/yorkshire | |
# Add a field | |
PUT villas/_doc/yorkshire | |
{ | |
"message": "This is Yorkshire", | |
"weather": "mild" | |
} | |
GET villas/_doc/yorkshire | |
# Remove the doc | |
DELETE villas/_doc/yorkshire | |
GET villas/_doc/yorkshire | |
# Create some documents | |
POST villas/_doc/ | |
{ | |
"message": "This is Yorkshire", | |
"weather": "mild", | |
"name": "Yorkshire" | |
} | |
# Just one or two | |
POST villas/_doc/ | |
{ | |
"message": "These are the Yorkshire Lowlands", | |
"weather": "mild", | |
"nom": "Yorkshire Lowlands" | |
} | |
# Create some other documents | |
POST villas/_doc/ | |
{ | |
"message": "And here is Cornwall", | |
"weather": "cold", | |
"name": "Cornwall" | |
} | |
POST villas/_doc/ | |
{ | |
"message": "Brighton is an old tourist destination", | |
"weather": "warm", | |
"name": "Brighton" | |
} | |
#### SEARCH | |
# Search all | |
GET villas/_search | |
GET villas/_mapping | |
# Why this difference? | |
GET villas/_search | |
{ | |
"query": { | |
"term": { | |
"message": "Yorkshire" | |
} | |
} | |
} | |
GET villas/_search | |
{ | |
"query": { | |
"term": { | |
"message": "yorkshire" | |
} | |
} | |
} | |
GET villas/_search | |
{ | |
"query": { | |
"match": { | |
"message": "yorkshire" | |
} | |
} | |
} | |
GET villas/_search | |
{ | |
"query": { | |
"match": { | |
"message": "YORKSHIRE!" | |
} | |
} | |
} | |
GET villas/_search | |
{ | |
"query": { | |
"match": { | |
"message": "yorkshire lowlands" | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment