`

ElasticSearch DSL 示例

阅读更多
PUT /megacorp/employee/4
{
  "first_name": "Jay",
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music",
  "interests": [
    "sports",
    "music"
  ]
}

POST /megacorp/employee
{
  "first_name": "Jay",
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music",
  "interests": [
    "sports",
    "music"
  ]
}

GET /megacorp/employee/_search
{
  "query": {
    "match": {
      "about": "cabinets"
    }
  }
}

GET /megacorp/employee/_search
{
  "query": {
    "match_phrase": {
      "about": "build cabinets"
    }
  }
}

GET /megacorp/employee/1

GET /megacorp/employee/1?pretty

GET /megacorp/employee/_search

GET /megacorp/employee/_search?q=last_name:Zhong

GET /megacorp/employee/_search
{
  "query": {
    "match": {
      "last_name": "Zhong"
    }
  }
}

GET /megacorp/employee/_search
{
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "age": {
            "lt": 30
          }
        }
      },
      "query": {
        "match": {
          "last_name": "Zhong"
        }
      }
    }
  }
}

GET /megacorp/employee/_search
{
  "query": {
    "match": {
      "last_name": "Zhong"
    }
  },
  "highlight": {
    "fields": {
      "last_name": {}
    }
  }
}

GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

GET /megacorp/employee/_search
{
  "query": {
    "match": {
      "last_name": "Zhong"
    }
  },
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      },
      "aggs": {
        "avg_age": {
          "avg": {
            "field": "age"
          }
        }
      }
    }
  }
}

GET /_cluster/health

PUT /blogs
{
  "settings": {
    "number_of_shards": 6,
    "number_of_replicas": 1
  }
}

PUT /blogs/_settings
{
  "number_of_replicas": 0
}

GET /megacorp/employee/_search?_source=age,interests

GET /megacorp/employee/1

GET /megacorp/employee/1/_source

PUT /website/blog/2?op_type=create
{
  "first_name": "Jay",
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music",
  "interests": [
    "sports",
    "music"
  ]
}

PUT /website/blog/122/_create
{
  "first_name": "Jay",
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music",
  "interests": [
    "sports",
    "music"
  ]
}

DELETE /website/blog/2

PUT /website/blog/2?version=13&version_type=external
{
  "title": "My first external blog entry",
  "text": "This is a piece of cake..."
}

GET /website/blog/2

POST /website/blog/2/_update
{
  "doc": {
    "tags": [
      "testing"
    ],
    "views": 0
  }
}

POST /_mget
{
  "docs": [
    {
      "_index": "website",
      "_type": "blog",
      "_id": 2
    },
    {
      "_index": "megacorp",
      "_type": "employee",
      "_id": 1,
      "_source": "age"
    }
  ]
}

POST /megacorp/employee/_mget
{
  "ids": [
    "2",
    "111"
  ]
}

POST /_bulk
{"delete":{"_index":"website","_type":"blog","_id":"223"}}
{"create":{"_index":"website","_type":"blog","_id":"223"}}
{"title":"My first blog post"}
{"index":{"_index":"website","_type":"blog"}}
{"title":"My second blog post"}
{"update":{"_index":"website","_type":"blog","_id":"223","_retry_on_conflict":3}}
{"doc":{"text":"My updated blog post"}}

POST /_bulk
{"create":{"_index":"website","_type":"blog","_id":"123"}}
{"title":"Cannot create - it already exists"}
{"index":{"_index":"website","_type":"blog","_id":"123"}}
{"title":"My first external blog entry","text":"This is a piece of cake..."}

POST /website/blog/_search

GET /megacorp/_search

GET /megacorp/employee/_mapping

GET /_analyze?analyzer=english
{
  "text": "Textes to analyze 5 32 遭受到"
}


GET megacorp/employee/_mapping

DELETE /megacorp2

PUT /megacorp2
{
  "mappings": {
    "employee": {
      "properties": {
        "about": {
          "type": "string",
          "analyzer": "english"
        },
        "age": {
          "type": "long"
        },
        "first_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "interests": {
          "type": "string"
        },
        "last_name": {
          "type": "string",
          "index": "no"
        }
      }
    }
  }
}


PUT /megacorp2/_mapping/employee
{
  "properties": {
    "about": {
      "type": "string",
      "analyzer": "english"
    },
    "age": {
      "type": "long"
    },
    "first_name": {
      "type": "string",
      "index": "not_analyzed"
    },
    "interests": {
      "type": "string"
    },
    "last_name": {
      "type": "string",
      "index": "no"
    }
  }
}

PUT /megacorp2/employee/1
{
  "first_name": "Jays 我",
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music 我饿么",
  "interests": [
    "sports",
    "music"
  ]
}

POST /megacorp2/employee
{
  "first_name": "Jays efe我",
  "last_name": "Smith",
  "age": 27,
  "about": "sfdf does you're I love rock music 我饿么",
  "interests": [
    "sports",
    "music"
  ]
}

PUT /megacorp/employee/66
{
  "first_name": [
    "sports",
    "music"
  ],
  "last_name": "Smith",
  "age": 27,
  "about": "I love rock music 我饿么",
  "interests": [
    "sports",
    "music"
  ]
}


GET /megacorp2/_search
{
  "query": {
    "match": {
      "last_name": "Smith"
    }
  }
}

POST megacorp/_search

PUT gb
{
  "tweet": {
    "properties": {
      "tweet": {
        "type": "string"
      },
      "user": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "gender": {
            "type": "string"
          },
          "age": {
            "type": "long"
          },
          "name": {
            "type": "object",
            "properties": {
              "full": {
                "type": "string"
              },
              "first": {
                "type": "string"
              },
              "last": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}


PUT gb/tweet/1
{
  "tweet": "Elasticsearch is very flexible",
  "user": {
    "id": "@johnsmith",
    "gender": "male",
    "age": 26,
    "name": {
      "full": "John Smith",
      "first": "John",
      "last": "Smith"
    }
  }
}

GET /gb/tweet/_search?pretty

GET /gb/tweet/_validate/query?explain
{
  "query": {
    "match": {
      "tweet": "really powerful"
    }
  }
}

GET /_search
{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "email": "business opportunity"
        }
      },
      "filter": {
        "term": {
          "folder": "inbox"
        }
      }
    }
  }
}

GET /_search
{
  "query": {
    "filtered": {
      "filter": {
        "term": {
          "user_id": 1
        }
      }
    }
  },
  "sort": {
    "date": {
      "order": "desc"
    }
  }
}

GET gb/tweet/_search

GET gb/tweet/_search
{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "tweet": "Elasticsearch is very flexible"
        }
      },
      "filter": {
        "term": {
          "user.id": "@johnsmith"
        }
      }
    }
  },
  "sort": [
    {
      "user.id": {
        "order": "desc"
      }
    },
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

GET /gb/tweet/1/_explain
{
  "query": {
    "filtered": {
      "filter": {
        "term": {
          "user.id": "@johnsmith"
        }
      },
      "query": {
        "match": {
          "tweet": "Elasticsearch is very flexible"
        }
      }
    }
  }
}


GET /gb/tweet/1/_explain
{
  "query": {
    "filtered": {
      "filter": {
        "term": {
          "user.id": "@johnsmith"
        }
      },
      "query": {
        "match": {
          "tweet": "Elasticsearch"
        }
      }
    }
  }
}

GET /megacorp/_search?search_type=scan&scroll=1m
{
  "query": {
    "match_all": {}
  },
  "size": 1000
}


 

 

分享到:
评论

相关推荐

    bboss+es基本操作示例.zip

    bboss+es基本操作示例,elasticsearch,bboss,java使用demo

    django-rest-elasticsearch:Elasticsearch对Django REST Framework的支持

    让我们看一个使用Django REST Elasticsearch构建简单应用程序的快速示例。 使用pip安装... pip install django-rest-elasticsearch 让我们创建一个简单的Django模型 class Blog ( models . Model ): title = ...

    Elasticsearch 技术解析与实战.zip

    前言 第1章 Elasticsearch入门 1 1.1 Elasticsearch是什么 1 1.1.1 Elasticsearch的历史 2 1.1.2 相关产品 3 1.2 全文搜索 3 1.2.1 Lucene介绍 4 1.2.2 Lucene倒排索引 4 1.3 基础知识 6 1.3.1 Elasticsearch术语及...

    bodybuilder:Elasticsearch查询主体构建器

    Elasticsearch兼容性当前旨在支持所有版本的完整Elasticsearch查询DSL。 通过调用build函数时提供v1参数来支持elasticsearch 1.x查询DSL。安装npm install bodybuilder --save用法var bodybuilder = require ( '...

    Python插入Elasticsearch操作方法解析

    这篇文章主要介绍了Python插入Elasticsearch操作方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 在用scrapy做爬虫的时候,需要将数据存入的es中。网上...

    helm-monitor:监视K8S Helm的发布,回退度量标准行为(Prometheus,Elasticsearch,Sentry)

    Helm Monitor插件监视发行版,并根据PromQL(Prometheus),事件(Sentry),Lucene或DSL查询(Elasticsearch)的结果回滚到以前的版本。演示版安装$ helm plugin install ...

    botanist:用于根据结构规则遍历和转换数据JavaScript DSL

    植物学家 一个JavaScript DSL,用于使用关于树状结构组成部分的规则来驯服树状结构。 受Parslet的启发,Botanist允许您通过描述您感兴趣的特定成分的结构来定义任意复杂数据的转换。入门植物学变换由一个或多个规则...

    qlbridge:一个golang表达式评估器和库,用于构建基于SQL查询引擎的功能

    QLBridge的功能和目标表达式引擎,用于评估单个表达式对您的数据执行sql查询,可嵌入,未与存储层耦合通过自定义go功能扩展VM,提供丰富的基本功能库提供示例后端(csv,elasticsearch等)方言SQL具有更多DSL过滤器...

    purescript-ui:缺少的 PureScript 库

    一些用法见示例目录。 目录安装你可以从凉亭安装它 bower install -S purescript-ui动机所有好的图书馆都值得一些动力。 创建 UI 很困难。 创建好的 UI 更难。 创建 UI 应该不难。 该库旨在简化 UI 的创建。 目标是...

    harmonyos2-react-primer-draft:使用React构建Web应用程序的入门

    ES2015(进行中) 目录 作者注 本入门书使用了多个库,但绝不是“以正确的方式React”。 这只是对我如何构建自己的 React 应用程序的介绍。 这本入门读物的目标是帮助开发人员熟悉 React 并直接投入。也许您会想出更...

    springboot参考指南

    连接Elasticsearch ii. 29.5.2. Spring Data Elasticseach仓库 ix. 30. 消息 i. 30.1. JMS i. 30.1.1. HornetQ支持 ii. 30.1.2. ActiveQ支持 iii. 30.1.3. 使用JNDI ConnectionFactory iv. 30.1.4. 发送消息 v. ...

Global site tag (gtag.js) - Google Analytics