Elasticsearch是一个开源搜索引擎,它提供了一个基于RESTful API的全文搜索和分析引擎。以下是一些基本的Elasticsearch查询操作:

  1. 查询所有文档:
GET /_search
{
    "query": {
        "match_all": {}
    }
}
  1. 精确匹配查询:
GET /_search
{
    "query": {
        "match": {
            "title": "Elasticsearch"
        }
    }
}
  1. 多个匹配查询:
GET /_search
{
    "query": {
        "multi_match": {
            "query": "Elasticsearch",
            "fields": ["title", "content"]
        }
    }
}
  1. 范围查询:
GET /_search
{
    "query": {
        "range": {
            "age": {
                "gte": 18,
                "lte": 30
            }
        }
    }
}
  1. 布尔查询:
GET /_search
{
    "query": {
        "bool": {
            "must": [
                { "match": { "title": "Elasticsearch" } },
                { "match": { "content": "search" } }
            ],
            "must_not": [
                { "match": { "status": "draft" } }
            ],
            "should": [
                { "match": { "author": "John" } },
                { "match": { "author": "Jane" } }
            ]
        }
    }
}

这些只是Elasticsearch查询的一些基本操作,还有很多其他的查询类型和参数可以使用。要深入了解Elasticsearch查询,请查看官方文档

elastic search query怎么用?

原文地址: https://www.cveoy.top/t/topic/dJs1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录