This is the 16th day of my participation in the August More Text Challenge. For details, see: August More Text Challenge
If ❤️ my article is helpful, welcome to like, follow. This is the greatest encouragement for me to continue my technical creation. More past articles in my personal column
Usage of ElasticSearch 7
The index
Create indexes
This API is used to create indexes, either automatically when the user passes the JSON object to the index, or manually before that. To create an index, you only need to send a POST request with Settings, Mappings, and aliases, or just a simple request with no body. For example,
PUT /material_pass_category
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"bak_code": {
"type": "text"
},
"category": {
"type": "keyword"
},
"collection_num": {
"type": "integer"
},
"cost": {
"type": "long"
},
"create_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis"
},
"file_name": {
"type": "text",
"fielddata": true
},
"half_year_pay_precent": {
"type": "float"
},
"half_year_roi": {
"type": "float"
},
"show_file_name": {
"type": "text",
"fielddata": true
}
}
}
}
Copy the code
Remove the index
To DELETE an index, a DELETE request must be initiated
DELETE http://localhost:9200/material_pass_category
Copy the code
Also can directly use the curl -x DELETE http://localhost:9200/material_pass_category removed
The document
Create a document
POST http://localhost:9200/material_pass_category/_doc/
{
"m_id": 59108,
"source_id": 304282,
"file_name": "0714zw\u5973\uff09-\u7ad6\u7248 -514e1.mp4",
"show_file_name": "0714zw\u5973\uff09-\u7ad6\u7248 -514e1.mp4",
"file_src": "material_pass\/zhangwsan\/",
"user_id": 378,
"user_name": "zhangwsan",
"designer_name": "\u5f20",
"file_name_aggs": "0714zw\u5973\uff09-\u7ad6\u7248 -514e1.mp4",
"material_size": "1080x1920",
"creativity_first": ",448,",
"creativity_second": ",2408,",
"creativity_third": ",2398,",
"free_tag": ",\u771f\u4eba\u5267\u60c5, ,\u5f02\u517d, ,UE4, ,\u5f02\u517d, ,\u5f02\u517d\u5bf9\u6bd4, ,\u5373\u5408, ,\u5f02\u517d\u56de\u6536, ,\u7535\u68af, ,\u5f02\u517d\u6355\u6349, ,\u6211\u5728\u6c5f\u6e56, ,\u4ed9\u4fa0, ,\u89c6\u9891, ,1080x1920, ,ALL,",
"game": ",968,",
"game_type": ",36,",
"material_pass": ",41,",
"platform": ",133,",
}
Copy the code
The query
GET /material_pass_category/_search? q=title:Beautiful Mind { "profile":"true" }Copy the code
Request Body and Query DSL
# ignore_unavailable = true, POST /material_pass_category,404_idx/_search? ignore_unavailable=true { "profile": true, "query": { "match_all": {} } } POST /kibana_sample_data_ecommerce/_search { "from":10, "size":20, "query":{ "match_all": POST kibanA_sample_datA_ecommerce /_search {" sort":[{"order_date":"desc"}], "query":{"match_all": {} } } #source filtering POST kibana_sample_data_ecommerce/_search { "_source":["order_date"], "query":{ "match_all": {"new_field": {"script": {"lang": {"new_field": {"script": {"lang": "painless", "source": "doc['order_date'].value+'hello'" } } }, "query": { "match_all": {} } } POST material_pass_category/_search { "query": { "match": { "title": "last christmas" } } } POST material_pass_category/_search { "query": { "match": { "title": { "query": "last christmas", "operator": "and" } } } } POST material_pass_category/_search { "query": { "match_phrase": { "title":{ "query": "one love" } } } } POST material_pass_category/_search { "query": { "match_phrase": { "title":{ "query": "one love", "slop": 1 } } } }Copy the code
reading
- www.elastic.co/guide/en/el…
- www.elastic.co/guide/en/el…