POST /customer/type1/_bulk
{"index":{"_id":"1"}}
{"age":30}
{"index":{"_id":"2"}}
{"age":40}
{"index":{"_id":"3"}}
{"age":50}
GET /customer/type1/_search
GET kibana_sample_data_flights/_search?q=*&sort=AvgTicketPrice:desc
GET kibana_sample_data_flights/_search?q=OriginWeather:Sunny AND OriginCountry:DE&_source=AvgTicketPrice,DestWeather&sort=AvgTicketPrice:desc
#This will fail to execute because 'match' doesn't support multiple fields
POST kibana_sample_data_flights/_search
{
"query" : {"match" : {"DestCountry" : "US", "FlightNum" : "C2YBQ05"}},
"sort" : {"AvgTicketPrice" : "desc"},
"_source" : ["AvgTicketPrice", "FlightNum"]
}
#This will successfully retrieve data (notice that square brackets enclose the conditions of 'must' )
POST kibana_sample_data_flights/_search
{
"query" : {
"bool" : {
"must" : [{
"match" :{
"DestCountry" : "US"
}},{
"match" : {
"FlightNum" : "C2YBQ05"
}}]
}
},
"sort" : {"AvgTicketPrice" : "desc"},
"_source" : ["AvgTicketPrice", "FlightNum"]
}
Add a backslash prefix before the whitespace character:
GET exam2/tourcompany/_search?q=Departure\ Date:2023-05-10
_id
is specified for a doc creationPUT /testindex/testtype/1 <- '_id' is set to '1'
{
"Name":"Milliam"
}
PUT /testindex/testtype/_create <- '_id' is set to '_create'
{
"Name":"Milliam2"
}
bool
keywordPOST exam2/tourcompany/_update_by_query
{
"script" : { "inline" : "ctx._source['Phone'] = '111-1111-1111'", "lang" : "painless"},
"query" : {
"bool":{
"must" : [
{"match" : {"Name" : "Chulsu"}}
],
"must_not" : [
{"match" : {"Name" : "This will not be matched"}}
]
}
}
}
query
keywordPOST exam2/tourcompany/_update_by_query
{
"script": {
"source": "ctx._source['Phone'] = '111-1111-1111'",
"lang": "painless"
},
"query": {
"match": {
"Name": "Chulsu"
}
}
}
DELETE
methodDELETE /customer/type1/1
Name : Chulsu
.POST /exam2/tourcompany/_delete_by_query
{
"query": {
"match": {
"Name": "Chulsu"
}
}
}
POST exam2/tourcompany/_delete_by_query?q=Name:Chulsu
POST exam2/tourcompany/_delete_by_query?q=Chulsu
The instruction above iterates through docs within the type customerlist
, deleting a doc if conditions are matched.
When creating a doc, the _mapping
object is automatically constructed. It contains properties related to the doc. The properties is a definition of each field in the doc, which is structured as follows:
Be aware that the types of fields are included in them. Once a type of field is defined, it could never be changed. If you try inserting different data, it would result in errors:
Name
If you run the below command, it would return errors:
GET exam2/tourcompany/_search?q=*&sort=Name:desc
The errors indicate that the use of a keyword
field is necessary:
The keyword
field is used as follows:
GET exam2/tourcompany/_search?q=*&sort=Name.keyword:desc