您的位置:首页 > 房产 > 家装 > 科技小手工_广州网站建设找哪里_免费视频网站推广软件_广州seo优化推广

科技小手工_广州网站建设找哪里_免费视频网站推广软件_广州seo优化推广

2025/1/15 6:26:41 来源:https://blog.csdn.net/qq_31679735/article/details/142790136  浏览:    关键词:科技小手工_广州网站建设找哪里_免费视频网站推广软件_广州seo优化推广
科技小手工_广州网站建设找哪里_免费视频网站推广软件_广州seo优化推广

# Creating a text file with the described Elasticsearch operations.

es_operations = """

Elasticsearch 基本操作语法:

1. 索引文档 (Index Documents):

   自动生成 ID:

   POST /index_name/_doc

   {

     "field1": "value1",

     "field2": "value2"

   }

   指定 ID:

   PUT /index_name/_doc/1

   {

     "field1": "value1",

     "field2": "value2"

   }

2. 获取文档 (Get Documents):

   按 ID 获取:

   GET /index_name/_doc/1

3. 更新文档 (Update Documents):

   部分更新文档:

   POST /index_name/_update/1

   {

     "doc": {

       "field2": "new_value"

     }

   }

4. 删除文档 (Delete Documents):

   按 ID 删除:

   DELETE /index_name/_doc/1

5. 查询文档 (Search Documents):

   Match 查询:

   GET /index_name/_search

   {

     "query": {

       "match": {

         "field1": "value"

       }

     }

   }

   Term 查询:

   GET /index_name/_search

   {

     "query": {

       "term": {

         "field1": "exact_value"

       }

     }

   }

   Bool 查询:

   GET /index_name/_search

   {

     "query": {

       "bool": {

         "must": [

           { "match": { "field1": "value" } },

           { "term": { "field2": "exact_value" } }

         ],

         "must_not": [

           { "term": { "field3": "value_to_exclude" } }

         ],

         "should": [

           { "match": { "field4": "optional_value" } }

         ]

       }

     }

   }

{

  "multi_match": {

    "query": "search text",

    "fields": ["field1", "field2", "field3"]

  }

}

6. 范围查询 (Range Queries):

   GET /index_name/_search

   {

     "query": {

       "range": {

         "timestamp": {

           "gte": "2024-01-01",

           "lte": "2024-12-31"

         }

       }

     }

   }

7. 聚合查询 (Aggregations):

   按字段分组 (Terms Aggregation):

  GET /index_name/_search

   {

     "size": 0,

     "aggs": {

       "group_by_field1": {

         "terms": {

           "field": "field1.keyword"

         }

       }

     }

   }

   统计 (Stats Aggregation):

  GET /index_name/_search

   {

     "size": 0,

     "aggs": {

       "field1_stats": {

         "stats": {

           "field": "field1"

         }

       }

     }

   }

8. 排序 (Sort):

   GET /index_name/_search

   {

     "query": {

       "match_all": {}

     },

     "sort": [

       { "field1": { "order": "asc" } },

       { "field2": { "order": "desc" } }

     ]

   }

9. 分页 (Pagination):

  GET /index_name/_search

   {

     "query": {

       "match_all": {}

     },

     "from": 0,

     "size": 10

   }

10. 批量操作 (Bulk Operations):

    POST /_bulk

    { "index": { "_index": "index_name", "_id": "1" } }

    { "field1": "value1" }

    { "delete": { "_index": "index_name", "_id": "2" } }

    { "update": { "_index": "index_name", "_id": "3" } }

    { "doc": { "field2": "new_value" } }

11. 滚动查询 (Scroll Query):

POST /index_name/_search?scroll=1m

    {

      "size": 100,

      "query": {

        "match_all": {}

      }

    }

    使用 _scroll_id 获取后续批次数据:

    POST /_search/scroll

    {

      "scroll": "1m",

      "scroll_id":"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAABbZjaFl1N3dLcmJNTE1GZ1BQOGZqZ3cAAAAAAA"

    }

12. 删除索引 (Delete Index):

    DELETE /index_name

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com