本文主要是介绍ES DSL,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
GET movie_index/movie/3
PUT movie_index/movie/3
{
"id": "3",
"name": "incident red sea",
"doubanScore": "5.0",
"actorList": [
{
"id": "1",
"name": "zhang chen"
}
]
}
POST movie_index/movie/3/_update
{
"doc":{
"doubanScore": "9.9"
}
}
DELETE movie_index/movie/3
GET movie_index/movie/_search
GET movie_index/movie/_search
{
"query":{
"match": {"name": "red"}
}
}
GET movie_index/movie/_search
{
"query":{
"match_phrase":{
"name": "operation red"
}
}
}
GET movie_index/movie/_search
{
"query":{
"fuzzy":{
"name": "sea"
}
}
}
GET movie_index/movie/_search
{
"query": {
"match": {
"name": "red"
}
},"post_filter": {
"term":{
"actorList.id": 3
}
}
}
## 查询后过滤
GET movie_index/movie/_search
{
"query": {
"bool": {
"filter": {"term": {
"actorList.id": 1
}},
"must": {
"match":{
"name": "red"
}
}
}
}
}
## 范围过滤
## gt gte greater than or equal
## lt lte less than or equal
GET movie_index/movie/_search
{
"query": {
"bool": {
"filter": {
"range": {
"doubanScore": {"gte": 8}
}
}
}
}
}
## 排序
GET movie_index/movie/_search
{
"query":{
"match": {"name":"red sea"}
}
, "sort": [
{
"doubanScore": {
"order": "desc"
}
}
]
}
## 分页查询
GET movie_index/movie/_search
{
"query": { "match_all": {} },
"from": 1,
"size": 1
}
## 指定字段
GET movie_index/movie/_search
{
"query": {
"match_all": {}
},
"_source": [
"name",
"doubanScore"
]
}
## 聚合
GET movie_index/movie/_search
{
"aggs": {
"groupby_actor": {
"terms": {
"field": "actorList.name.keyword"
}
}
}
}
GET movie_index/movie/_search
{
"aggs": {
"groupby_actor_id": {
"terms": {
"field": "actorList.name.keyword" ,
"order": {
"avg_score": "desc"
}
},
"aggs": {
"avg_score":{
"avg": {
"field": "doubanScore"
}
}
}
}
}
}
这篇关于ES DSL的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!