package com.alatus.search; import com.alatus.search.config.MallElasticSearchConfig; import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.Avg; import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; import java.util.List; import java.util.Map; @RunWith(SpringRunner.class) @SpringBootTest public class TestLoad { @Autowired private RestHighLevelClient client; @Test public void load(){ System.out.println(client); } @Test public void index() throws IOException { IndexRequest request = new IndexRequest("users"); request.id("1"); request.source("username","Jack","age",18,"gender","男"); String jsonString = JSON.toJSONString(new User("Rose", 18, "女")); request.source(jsonString, XContentType.JSON); // 执行操作 IndexResponse index = client.index(request, MallElasticSearchConfig.COMMON_OPTIONS); System.out.println(index); } @Test public void searchData() throws IOException { // 创建检索请求 SearchRequest searchRequest = new SearchRequest(); // 指定索引 searchRequest.indices("bank"); // 指定DSL,检索条件 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); // 检索条件 searchSourceBuilder.query(QueryBuilders.matchQuery("address","mill")); searchSourceBuilder.from(1); searchSourceBuilder.size(10); // 设置聚合条件 // 按照年龄的值做了一次聚合 TermsAggregationBuilder ageAgg = AggregationBuilders.terms("ageAgg").field("age").size(1); searchSourceBuilder.aggregation(ageAgg); // 按照平均工资做一次聚合 AvgAggregationBuilder balanceAgg = AggregationBuilders.avg("balanceAvg").field("balance"); searchSourceBuilder.aggregation(balanceAgg); searchRequest.source(searchSourceBuilder); // 打印检索条件 System.out.println(searchRequest); // 执行检索 SearchResponse searchResponse = client.search(searchRequest, MallElasticSearchConfig.COMMON_OPTIONS); // 获取所有命中的记录 // 这里是转为map对象 Map map = JSON.parseObject(searchResponse.toString(), Map.class); // 获取命中的记录 SearchHits hits = searchResponse.getHits(); SearchHit[] searchHits = hits.getHits(); for (SearchHit searchHit : searchHits) { System.out.println(searchHit.getIndex()); System.out.println(searchHit.getId()); // Map<String, Object> sourceAsMap = searchHit.getSourceAsMap(); String sourceAsString = searchHit.getSourceAsString(); Account account = JSON.parseObject(sourceAsString, Account.class); System.out.println(account); } System.out.println(map); System.out.println(searchResponse); // 获取检索到的分析信息 Aggregations aggregations = searchResponse.getAggregations(); List<Aggregation> list = aggregations.asList(); for (Aggregation aggregation : list) { System.out.println(aggregation.getName()); } Terms ageAggTon = aggregations.get("ageAgg"); for (Terms.Bucket bucket : ageAggTon.getBuckets()) { System.out.println("年龄"+bucket.getKeyAsString()); System.out.println(bucket.getDocCount()); } Avg balanceAvg = aggregations.get("balanceAvg"); System.out.println("平均薪资"+balanceAvg.getValue()); } @Data @AllArgsConstructor @NoArgsConstructor class User{ private String username; private Integer age; private String gender; } @Data @NoArgsConstructor @AllArgsConstructor @ToString static class Account{ /** * Copyright 2024 bejson.com */ /** * Auto-generated: 2024-07-17 13:20:0 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ private int account_number; private int balance; private String firstname; private String lastname; private int age; private String gender; private String address; private String employer; private String email; private String city; private String state; } }
package com.alatus.search; import com.alatus.search.config.MallElasticSearchConfig; import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.Avg; import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; import java.util.List; import java.util.Map; @RunWith(SpringRunner.class) @SpringBootTest public class TestLoad { @Autowired private RestHighLevelClient client; @Test public void load(){ System.out.println(client); } @Test public void index() throws IOException { IndexRequest request = new IndexRequest("users"); request.id("1"); request.source("username","Jack","age",18,"gender","男"); String jsonString = JSON.toJSONString(new User("Rose", 18, "女")); request.source(jsonString, XContentType.JSON); // 执行操作 IndexResponse index = client.index(request, MallElasticSearchConfig.COMMON_OPTIONS); System.out.println(index); } @Test public void searchData() throws IOException { // 创建检索请求 SearchRequest searchRequest = new SearchRequest(); // 指定索引 searchRequest.indices("bank"); // 指定DSL,检索条件 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); // 检索条件 searchSourceBuilder.query(QueryBuilders.matchQuery("address","mill")); searchSourceBuilder.from(1); searchSourceBuilder.size(10); // 设置聚合条件 // 按照年龄的值做了一次聚合 TermsAggregationBuilder ageAgg = AggregationBuilders.terms("ageAgg").field("age").size(1); searchSourceBuilder.aggregation(ageAgg); // 按照平均工资做一次聚合 AvgAggregationBuilder balanceAgg = AggregationBuilders.avg("balanceAvg").field("balance"); searchSourceBuilder.aggregation(balanceAgg); searchRequest.source(searchSourceBuilder); // 打印检索条件 System.out.println(searchRequest); // 执行检索 SearchResponse searchResponse = client.search(searchRequest, MallElasticSearchConfig.COMMON_OPTIONS); // 获取所有命中的记录 // 这里是转为map对象 Map map = JSON.parseObject(searchResponse.toString(), Map.class); // 获取命中的记录 SearchHits hits = searchResponse.getHits(); SearchHit[] searchHits = hits.getHits(); for (SearchHit searchHit : searchHits) { System.out.println(searchHit.getIndex()); System.out.println(searchHit.getId()); // Map<String, Object> sourceAsMap = searchHit.getSourceAsMap(); String sourceAsString = searchHit.getSourceAsString(); Account account = JSON.parseObject(sourceAsString, Account.class); System.out.println(account); } System.out.println(map); System.out.println(searchResponse); // 获取检索到的分析信息 Aggregations aggregations = searchResponse.getAggregations(); List<Aggregation> list = aggregations.asList(); for (Aggregation aggregation : list) { System.out.println(aggregation.getName()); } Terms ageAggTon = aggregations.get("ageAgg"); for (Terms.Bucket bucket : ageAggTon.getBuckets()) { System.out.println("年龄"+bucket.getKeyAsString()); System.out.println(bucket.getDocCount()); } Avg balanceAvg = aggregations.get("balanceAvg"); System.out.println("平均薪资"+balanceAvg.getValue()); } @Data @AllArgsConstructor @NoArgsConstructor class User{ private String username; private Integer age; private String gender; } @Data @NoArgsConstructor @AllArgsConstructor @ToString static class Account{ /** * Copyright 2024 bejson.com */ /** * Auto-generated: 2024-07-17 13:20:0 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ private int account_number; private int balance; private String firstname; private String lastname; private int age; private String gender; private String address; private String employer; private String email; private String city; private String state; } }
/** * Copyright 2024 bejson.com */ package com.bejson.pojo; /** * Auto-generated: 2024-07-17 13:20:0 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ public class JsonRootBean { private int account_number; private int balance; private String firstname; private String lastname; private int age; private String gender; private String address; private String employer; private String email; private String city; private String state; public void setAccount_number(int account_number) { this.account_number = account_number; } public int getAccount_number() { return account_number; } public void setBalance(int balance) { this.balance = balance; } public int getBalance() { return balance; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getFirstname() { return firstname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getLastname() { return lastname; } public void setAge(int age) { this.age = age; } public int getAge() { return age; } public void setGender(String gender) { this.gender = gender; } public String getGender() { return gender; } public void setAddress(String address) { this.address = address; } public String getAddress() { return address; } public void setEmployer(String employer) { this.employer = employer; } public String getEmployer() { return employer; } public void setEmail(String email) { this.email = email; } public String getEmail() { return email; } public void setCity(String city) { this.city = city; } public String getCity() { return city; } public void setState(String state) { this.state = state; } public String getState() { return state; } }
/**
* Copyright 2024 bejson.com
*/
package com.bejson.pojo;/**
* Auto-generated: 2024-07-17 13:20:0
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public class JsonRootBean {private int account_number;
private int balance;
private String firstname;
private String lastname;
private int age;
private String gender;
private String address;
private String employer;
private String email;
private String city;
private String state;
public void setAccount_number(int account_number) {
this.account_number = account_number;
}
public int getAccount_number() {
return account_number;
}public void setBalance(int balance) {
this.balance = balance;
}
public int getBalance() {
return balance;
}public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getFirstname() {
return firstname;
}public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getLastname() {
return lastname;
}public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}public void setGender(String gender) {
this.gender = gender;
}
public String getGender() {
return gender;
}public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}public void setEmployer(String employer) {
this.employer = employer;
}
public String getEmployer() {
return employer;
}public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}public void setCity(String city) {
this.city = city;
}
public String getCity() {
return city;
}public void setState(String state) {
this.state = state;
}
public String getState() {
return state;
}}
GET users/_search GET /bank/_search { "from": 1, "size": 10, "query": { "match": { "address": { "query": "mill", "operator": "OR", "prefix_length": 0, "max_expansions": 50, "fuzzy_transpositions": true, "lenient": false, "zero_terms_query": "NONE", "auto_generate_synonyms_phrase_query": true, "boost": 1 } } }, "aggregations": { "ageAgg": { "terms": { "field": "age", "size": 1, "min_doc_count": 1, "shard_min_doc_count": 0, "show_term_doc_count_error": false, "order": [ { "_count": "desc" }, { "_key": "asc" } ] } }, "balanceAvg": { "avg": { "field": "balance" } } } }
GET users/_search
GET /bank/_search
{
"from": 1,
"size": 10,
"query": {
"match": {
"address": {
"query": "mill",
"operator": "OR",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1
}
}
},
"aggregations": {
"ageAgg": {
"terms": {
"field": "age",
"size": 1,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{ "_count": "desc" },
{ "_key": "asc" }
]
}
},
"balanceAvg": {
"avg": {
"field": "balance"
}
}
}
}
{ "took" : 2, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 4, "relation" : "eq" }, "max_score" : 5.4032025, "hits" : [ { "_index" : "bank", "_type" : "account", "_id" : "136", "_score" : 5.4032025, "_source" : { "account_number" : 136, "balance" : 45801, "firstname" : "Winnie", "lastname" : "Holland", "age" : 38, "gender" : "M", "address" : "198 Mill Lane", "employer" : "Neteria", "email" : "winnieholland@neteria.com", "city" : "Urie", "state" : "IL" } }, { "_index" : "bank", "_type" : "account", "_id" : "345", "_score" : 5.4032025, "_source" : { "account_number" : 345, "balance" : 9812, "firstname" : "Parker", "lastname" : "Hines", "age" : 38, "gender" : "M", "address" : "715 Mill Avenue", "employer" : "Baluba", "email" : "parkerhines@baluba.com", "city" : "Blackgum", "state" : "KY" } }, { "_index" : "bank", "_type" : "account", "_id" : "472", "_score" : 5.4032025, "_source" : { "account_number" : 472, "balance" : 25571, "firstname" : "Lee", "lastname" : "Long", "age" : 32, "gender" : "F", "address" : "288 Mill Street", "employer" : "Comverges", "email" : "leelong@comverges.com", "city" : "Movico", "state" : "MT" } } ] }, "aggregations" : { "ageAgg" : { "doc_count_error_upper_bound" : 0, "sum_other_doc_count" : 2, "buckets" : [ { "key" : 38, "doc_count" : 2 } ] }, "balanceAvg" : { "value" : 25208.0 } } }
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : 5.4032025,
"hits" : [
{
"_index" : "bank",
"_type" : "account",
"_id" : "136",
"_score" : 5.4032025,
"_source" : {
"account_number" : 136,
"balance" : 45801,
"firstname" : "Winnie",
"lastname" : "Holland",
"age" : 38,
"gender" : "M",
"address" : "198 Mill Lane",
"employer" : "Neteria",
"email" : "winnieholland@neteria.com",
"city" : "Urie",
"state" : "IL"
}
},
{
"_index" : "bank",
"_type" : "account",
"_id" : "345",
"_score" : 5.4032025,
"_source" : {
"account_number" : 345,
"balance" : 9812,
"firstname" : "Parker",
"lastname" : "Hines",
"age" : 38,
"gender" : "M",
"address" : "715 Mill Avenue",
"employer" : "Baluba",
"email" : "parkerhines@baluba.com",
"city" : "Blackgum",
"state" : "KY"
}
},
{
"_index" : "bank",
"_type" : "account",
"_id" : "472",
"_score" : 5.4032025,
"_source" : {
"account_number" : 472,
"balance" : 25571,
"firstname" : "Lee",
"lastname" : "Long",
"age" : 32,
"gender" : "F",
"address" : "288 Mill Street",
"employer" : "Comverges",
"email" : "leelong@comverges.com",
"city" : "Movico",
"state" : "MT"
}
}
]
},
"aggregations" : {
"ageAgg" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 2,
"buckets" : [
{
"key" : 38,
"doc_count" : 2
}
]
},
"balanceAvg" : {
"value" : 25208.0
}
}
}
SearchRequest{searchType=QUERY_THEN_FETCH, indices=[bank], indicesOptions=IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=0, batchedReduceSize=512, preFilterShardSize=128, allowPartialSearchResults=null, localClusterAlias=null, getOrCreateAbsoluteStartMillis=-1, ccsMinimizeRoundtrips=true, source={"from":1,"size":10,"query":{"match":{"address":{"query":"mill","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},"aggregations":{"ageAgg":{"terms":{"field":"age","size":1,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"balanceAvg":{"avg":{"field":"balance"}}}}} bank 136 TestLoad.Account(account_number=136, balance=45801, firstname=Winnie, lastname=Holland, age=38, gender=M, address=198 Mill Lane, employer=Neteria, email=winnieholland@neteria.com, city=Urie, state=IL) bank 345 TestLoad.Account(account_number=345, balance=9812, firstname=Parker, lastname=Hines, age=38, gender=M, address=715 Mill Avenue, employer=Baluba, email=parkerhines@baluba.com, city=Blackgum, state=KY) bank 472 TestLoad.Account(account_number=472, balance=25571, firstname=Lee, lastname=Long, age=32, gender=F, address=288 Mill Street, employer=Comverges, email=leelong@comverges.com, city=Movico, state=MT) {_shards={"total":1,"failed":0,"successful":1,"skipped":0}, hits={"hits":[{"_index":"bank","_type":"account","_source":{"account_number":136,"firstname":"Winnie","address":"198 Mill Lane","balance":45801,"gender":"M","city":"Urie","employer":"Neteria","state":"IL","age":38,"email":"winnieholland@neteria.com","lastname":"Holland"},"_id":"136","_score":5.4032025},{"_index":"bank","_type":"account","_source":{"account_number":345,"firstname":"Parker","address":"715 Mill Avenue","balance":9812,"gender":"M","city":"Blackgum","employer":"Baluba","state":"KY","age":38,"email":"parkerhines@baluba.com","lastname":"Hines"},"_id":"345","_score":5.4032025},{"_index":"bank","_type":"account","_source":{"account_number":472,"firstname":"Lee","address":"288 Mill Street","balance":25571,"gender":"F","city":"Movico","employer":"Comverges","state":"MT","age":32,"email":"leelong@comverges.com","lastname":"Long"},"_id":"472","_score":5.4032025}],"total":{"value":4,"relation":"eq"},"max_score":5.4032025}, took=1, timed_out=false, aggregations={"lterms#ageAgg":{"doc_count_error_upper_bound":0,"sum_other_doc_count":2,"buckets":[{"doc_count":2,"key":38}]},"avg#balanceAvg":{"value":25208.0}}} {"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":4,"relation":"eq"},"max_score":5.4032025,"hits":[{"_index":"bank","_type":"account","_id":"136","_score":5.4032025,"_source":{"account_number":136,"balance":45801,"firstname":"Winnie","lastname":"Holland","age":38,"gender":"M","address":"198 Mill Lane","employer":"Neteria","email":"winnieholland@neteria.com","city":"Urie","state":"IL"}},{"_index":"bank","_type":"account","_id":"345","_score":5.4032025,"_source":{"account_number":345,"balance":9812,"firstname":"Parker","lastname":"Hines","age":38,"gender":"M","address":"715 Mill Avenue","employer":"Baluba","email":"parkerhines@baluba.com","city":"Blackgum","state":"KY"}},{"_index":"bank","_type":"account","_id":"472","_score":5.4032025,"_source":{"account_number":472,"balance":25571,"firstname":"Lee","lastname":"Long","age":32,"gender":"F","address":"288 Mill Street","employer":"Comverges","email":"leelong@comverges.com","city":"Movico","state":"MT"}}]},"aggregations":{"lterms#ageAgg":{"doc_count_error_upper_bound":0,"sum_other_doc_count":2,"buckets":[{"key":38,"doc_count":2}]},"avg#balanceAvg":{"value":25208.0}}} ageAgg balanceAvg 年龄38 2 平均薪资25208.0 2024-07-17 13:32:02.766 INFO 10088 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'Nacso-Watch-Task-Scheduler' 2024-07-17 13:32:02.772 INFO 10088 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
SearchRequest{searchType=QUERY_THEN_FETCH, indices=[bank], indicesOptions=IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=0, batchedReduceSize=512, preFilterShardSize=128, allowPartialSearchResults=null, localClusterAlias=null, getOrCreateAbsoluteStartMillis=-1, ccsMinimizeRoundtrips=true, source={"from":1,"size":10,"query":{"match":{"address":{"query":"mill","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},"aggregations":{"ageAgg":{"terms":{"field":"age","size":1,"min_doc_count":1,"shard_min_doc_count":0,"show_term_doc_count_error":false,"order":[{"_count":"desc"},{"_key":"asc"}]}},"balanceAvg":{"avg":{"field":"balance"}}}}}
bank
136
TestLoad.Account(account_number=136, balance=45801, firstname=Winnie, lastname=Holland, age=38, gender=M, address=198 Mill Lane, employer=Neteria, email=winnieholland@neteria.com, city=Urie, state=IL)
bank
345
TestLoad.Account(account_number=345, balance=9812, firstname=Parker, lastname=Hines, age=38, gender=M, address=715 Mill Avenue, employer=Baluba, email=parkerhines@baluba.com, city=Blackgum, state=KY)
bank
472
TestLoad.Account(account_number=472, balance=25571, firstname=Lee, lastname=Long, age=32, gender=F, address=288 Mill Street, employer=Comverges, email=leelong@comverges.com, city=Movico, state=MT)
{_shards={"total":1,"failed":0,"successful":1,"skipped":0}, hits={"hits":[{"_index":"bank","_type":"account","_source":{"account_number":136,"firstname":"Winnie","address":"198 Mill Lane","balance":45801,"gender":"M","city":"Urie","employer":"Neteria","state":"IL","age":38,"email":"winnieholland@neteria.com","lastname":"Holland"},"_id":"136","_score":5.4032025},{"_index":"bank","_type":"account","_source":{"account_number":345,"firstname":"Parker","address":"715 Mill Avenue","balance":9812,"gender":"M","city":"Blackgum","employer":"Baluba","state":"KY","age":38,"email":"parkerhines@baluba.com","lastname":"Hines"},"_id":"345","_score":5.4032025},{"_index":"bank","_type":"account","_source":{"account_number":472,"firstname":"Lee","address":"288 Mill Street","balance":25571,"gender":"F","city":"Movico","employer":"Comverges","state":"MT","age":32,"email":"leelong@comverges.com","lastname":"Long"},"_id":"472","_score":5.4032025}],"total":{"value":4,"relation":"eq"},"max_score":5.4032025}, took=1, timed_out=false, aggregations={"lterms#ageAgg":{"doc_count_error_upper_bound":0,"sum_other_doc_count":2,"buckets":[{"doc_count":2,"key":38}]},"avg#balanceAvg":{"value":25208.0}}}
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":4,"relation":"eq"},"max_score":5.4032025,"hits":[{"_index":"bank","_type":"account","_id":"136","_score":5.4032025,"_source":{"account_number":136,"balance":45801,"firstname":"Winnie","lastname":"Holland","age":38,"gender":"M","address":"198 Mill Lane","employer":"Neteria","email":"winnieholland@neteria.com","city":"Urie","state":"IL"}},{"_index":"bank","_type":"account","_id":"345","_score":5.4032025,"_source":{"account_number":345,"balance":9812,"firstname":"Parker","lastname":"Hines","age":38,"gender":"M","address":"715 Mill Avenue","employer":"Baluba","email":"parkerhines@baluba.com","city":"Blackgum","state":"KY"}},{"_index":"bank","_type":"account","_id":"472","_score":5.4032025,"_source":{"account_number":472,"balance":25571,"firstname":"Lee","lastname":"Long","age":32,"gender":"F","address":"288 Mill Street","employer":"Comverges","email":"leelong@comverges.com","city":"Movico","state":"MT"}}]},"aggregations":{"lterms#ageAgg":{"doc_count_error_upper_bound":0,"sum_other_doc_count":2,"buckets":[{"key":38,"doc_count":2}]},"avg#balanceAvg":{"value":25208.0}}}
ageAgg
balanceAvg
年龄38
2
平均薪资25208.0
2024-07-17 13:32:02.766 INFO 10088 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'Nacso-Watch-Task-Scheduler'
2024-07-17 13:32:02.772 INFO 10088 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'