es查询
GET test*/_search
{
"size": 10,
"from": 0 ,
"query": {
"term": {
"member_age" : 62
}
}
}
POST {index}/_update/{id}
{
"doc":{
"key":"value"
}
}
例句:查询member_gender为男的数据修改为女
POST {index}/_update_by_query
{
"script":{
"inline":"ctx._source.member_gender = params.member_gender",
"params": {
"member_gender": "女"
}
},
"query":{
"term":{
"member_gender" : "男"
}
}
}
POST wipro-headpic/_search?pretty
{
# 查询条件
"query":{
"term":{
"member_age":3
}
},
# 根据字段排序
"sort": [
{
"member_age": {
"order": "asc"
}
}
],
"size": 2, # 显示条数
# 聚合函数的聚合方法
"aggs": {
"maxage": {
"max": {
"field": "member_age"
}
}
}
}
POST wipro-headpic/_search?size=0
{
"aggs":{
"age_count":{
"value_count":{
"field" : "ordernum"
}
},
"name_count":{
"cardinality":{
"field" : "ordernum"
}
}
}
}
例
POST wipro-headpic/_search?size=1
{
"aggs":{
"age_count":{
"value_count":{
"field" : "ordernum"
}
},
"ordernum_count":{
"cardinality":{
"field" : "ordernum.keyword"
}
}
}
}
GET /_cat/segments/wipro-headpic?v&h=shard,segments,size,size.memory
GET /_cat/nodes?v&h=name,port,sm
POST wipro-headpic/_doc/dbmykm4Bz_XBJXPx0VE4
{
“member_gender” : “ee”,
“type” : “wipro-headpic”,
“customer_shop_id” : “uuuuuuuuuuuuuu”,
“member_age” : 68
}
#根据条件更新文档
POST wipro-headpic/_update_by_query
{
“script”:{
“inline”:“ctx._source.member_gender = params.member_gender”,
“params”: {
“member_gender”: “女”
}
},
“query”:{
“term”:{
“member_gender” : “男”
}
}
}
#聚合查询 查询最大最小值
POST wipro-headpic/_search?pretty
{
“size”: 1,
“aggs”: {
“maxage”: {
“max”: {
“field”: “member_age”
}
}
}
}
#聚合查询 查询最大最小值加条件
POST wipro-headpic/_search?pretty
{
“query”:{
“term”:{
“member_age”:3
}
},
“sort”: [
{
“member_age”: {
“order”: “asc”
}
}
],
“size”: 2,
“aggs”: {
“maxage”: {
“max”: {
“field”: “member_age”
}
}
}
}
PUT wipro-headpic/_mapping
{
“properties”: {
“interests”: {
“type”: “text”,
“fielddata”: true
}
}
}
POST wipro-headpic/_search?size=1
{
"aggs":{
"count":{
"value_count":{
"field" : "member_id.keyword"
}
},
"crad_count":{
"cardinality":{
"precision_threshold" : 12000,
"field" : "member_id.keyword"
}
}
}
}
GET /wipro-headpic/_doc/_search?q=member_age:44
{
“size”:1000
}
GET /wipro-headpic/_doc/_search?_source=member_age
{
“size”:1000
}
GET /wipro-headpic/_doc/_search
{
“size” :0,
“aggs” : {
“popular_age” : {
“terms” : {
“field” : “member_gender.keyword”,
“size”: 3
}
}
}
}
GET /wipro-headpic/_doc/_search
{
“size” :0,
“aggs” : {
“popular_age” : {
“terms” : {
“shard_size”:10,
“field” : “member_age”,
“size”: 3
}
}
}
}
GET /wipro-headpic/_doc/_search
{
“size” :0,
“aggs” : {
“popular_age” : {
“terms” : {
“size”:3,
“field” : “member_age”
}
}
}
}
GET /wipro-headpic/_doc/_search?size=0
{
“aggs” : {
“一级actors” : {
“terms” : {
“field” : “member_age”,
“size” : 3,
“shard_size” : 10,
“collect_mode” : “breadth_first”
},
“aggs” : {
“二级costars” : {
“terms” : {
“field” : “member_id.keyword”,
“size” : 5
}
}
}
}
}
}
GET /_cat/segments/wipro-headpic?v&h=shard,segments,size,size.memory
GET /_cat/nodes?v&h=name,port,sm
GET /_cat/segments/wipro-headpic?v&h=shard,name,port,segments,size,size.memory
GET /_stats/fielddata?fields=*
POST wipro-headpic/_search?size=1
{
"aggs":{
"count":{
"value_count":{
"field" : "member_id.keyword"
}
},
"crad_count":{
"cardinality":{
"precision_threshold" : 500,
"field" : "member_age"
}
}
}
}
GET /_search
{
“sort”:
{
“member_age”: “desc”
}
,
“from”:0,
“size”:4,
“query” : {
“bool” : {
“must” : {
“term”:{
“member_id” : “7992254”
}
},
“filter” : {
“range”: { “member_age”:{“gt”: 4995}}
}
}
}
}