package com.prime.demo.util;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import com.prime.demo.beans.ESDocument;
import com.prime.demo.multithread.MessageService;
import com.prime.mcms.base.beans.ArticleBean;
import com.prime.mcms.base.utils.DateUtil;
import com.prime.mcms.base.utils.SecurityUtil;
import com.prime.smm.base.beans.TweetDocument;
import com.prime.smm.base.utils.PropConfig;
import com.prime.smm.base.utils.json.JSONArray;
import com.prime.smm.base.utils.json.JSONException;
public class ElasticSearchUtils {
private static String clusterName = PropConfig.getFileConfig("elasticsearch", "es.clusterName");
private static String indexname= PropConfig.getFileConfig("elasticsearch", "es.indexname");
private static String indextype= PropConfig.getFileConfig("elasticsearch", "es.indextype");
private static String message = MessageService.getInstance(4) ;
static Map<String, String> m = new HashMap<String, String>();
// 设置client.transport.sniff为true来使客户端去嗅探整个集群的状态,把集群中其它机器的ip地址加到客户端中,
static Settings settings = ImmutableSettings.settingsBuilder().put(m).put("cluster.name",clusterName).put("client.transport.sniff", true).build();
public ElasticSearchUtils() {}
private static TransportClient client;
static {
try {
Class<?> clazz = Class.forName(TransportClient.class.getName());
Constructor<?> constructor = clazz.getDeclaredConstructor(Settings.class);
constructor.setAccessible(true);
client = (TransportClient) constructor.newInstance(settings);
client.addTransportAddress(new InetSocketTransportAddress("192.168.9.103", 9300));
client.addTransportAddress(new InetSocketTransportAddress("192.168.9.115", 9300));
client.addTransportAddress(new InetSocketTransportAddress("192.168.9.116", 9300));
} catch (Exception e) {
e.printStackTrace();
}
}
// 取得实例
public static synchronized TransportClient getTransportClient() {
return client;
}
public static void prepareIndex(){
IndexResponse response = client.prepareIndex("tweet", "tweet").setSource(message).execute().actionGet();
}
/**
* 插入数据
*/
public boolean bulkBuilder(List<ArticleBean> objects,String indexName,String indexType){
System.out.println(objects.size()) ;
if(objects!=null && objects.size()>0){
BulkRequestBuilder bulkRequest = client.prepareBulk();
for(ArticleBean article : objects){
System.out.println("--<>"+article.toString()) ;
IndexRequestBuilder indexRequest = client.prepareIndex(indexName, indexType).setSource(article.toString());
bulkRequest.add(indexRequest);
}
System.out.println(bulkRequest.toString()) ;
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
System.out.println(bulkResponse.buildFailureMessage());
return false;
}
return true ;
}
return false ;
}
public static void bulkBuilder(){
BulkRequestBuilder bulkRequest = client.prepareBulk();
IndexRequestBuilder indexRequest = client.prepareIndex("tweet", "tweet").setSource(message);
bulkRequest.add(indexRequest);
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
System.out.println(bulkResponse.buildFailureMessage());
}
}
public static void bulkBuilder(List<TweetDocument> docs){
if(docs!=null && docs.size()>0){
BulkRequestBuilder bulkRequest = client.prepareBulk();
for(TweetDocument tweet:docs){
IndexRequestBuilder indexRequest = client.prepareIndex("tweet", "tweet").setSource(tweet.toString()).setId(tweet.getFolderDocId());
bulkRequest.add(indexRequest);
}
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
System.out.println(bulkResponse.buildFailureMessage());
}
}
}
public static void bulkBuilderLists(List<ESDocument> docs){
long t1 = System.currentTimeMillis();
if(docs!=null && docs.size()>0){
BulkRequestBuilder bulkRequest = client.prepareBulk();
for(ESDocument tweet:docs){
String tweeString = tweet.toString() ;
String pMessage = ESDocument.parseParentDocument(tweeString).toString() ;
// System.out.println("pMessage::"+pMessage) ;
String cMessage = ESDocument.parseChildDocument(tweeString).toString() ;
// System.out.println("cMessage::"+cMessage) ;
IndexRequestBuilder indexRequest = client.prepareIndex("alert", "tweet").setSource(pMessage);
bulkRequest.add(indexRequest);
indexRequest = client.prepareIndex("alert", "index").setSource(cMessage).setParent(tweet.getFolderDocId());
bulkRequest.add(indexRequest);
}
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
System.out.println(bulkResponse.buildFailureMessage());
}
}
long t2 = System.currentTimeMillis();
System.out.println("ES index doc size:"+docs.size()+" ,cost:"+(t2-t1)/1000+"s");
}
public static void bulkProcess() {
BulkProcessor bulkProcessor = BulkProcessor.builder(client,
new BulkProcessor.Listener() {
long a = 0 ;
long b = 0 ;
public void beforeBulk(long executionId, BulkRequest request) {
a = System.currentTimeMillis() ;
System.out.println("beforeBulk numberOfActions = " + request.numberOfActions()+"|request:"+request.requests().size());
}
public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
b = System.currentTimeMillis() ;
System.out.println("afterBulk"+(b-a)+" ms");
}
//璁剧疆ConcurrentRequest 涓�锛孴hrowable涓嶆姏閿�
public void afterBulk(long executionId, BulkRequest request, Throwable failure) {
// System.out.println("happen fail = " + failure.getMessage() + " cause = " +failure.getCause());
}
})
.setBulkActions(10000)
.setBulkSize(new ByteSizeValue(20, ByteSizeUnit.MB))
.setFlushInterval(TimeValue.timeValueSeconds(5))
.setConcurrentRequests(10)
.build();
for(int i=0;i<1000;i++){
bulkProcessor.add(new IndexRequest("tweet", "tweet").source(message));
}
bulkProcessor.close();
client.close();
}
public static void updateIndexRequest(){
try {
UpdateRequest updateRequest = new UpdateRequest();
updateRequest.index("alert");
updateRequest.type("index");
updateRequest.parent("tweet"); //parent-child更新必须加上父类
updateRequest.id("3804792499471673");
// 更新ptIds
// String ptIds = "[{\"catId\":27607,\"catTitle\":\"英菲尼迪\",\"contentMention\":1,\"docId\":\"2015112500000413192\",\"level\":1,\"titleMention\":0,\"treeType\":1}]" ;
// updateRequest.doc(XContentFactory.jsonBuilder().startObject().field("ptIds", net.sf.json.JSONArray.fromObject(ptIds)).endObject());
updateRequest.doc(XContentFactory.jsonBuilder().startObject().field("activeCount", 123).endObject());
client.update(updateRequest).get();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 执行搜索
* @param queryBuilder
* @param indexname
* @param type
* @return
*/
public static void searcher(QueryBuilder queryBuilder, String indexname, String type){
SearchResponse searchResponse = client.prepareSearch(indexname).setTypes(type)
.setQuery(queryBuilder)
.execute()
.actionGet();
SearchHits hits = searchResponse.getHits() ;
System.out.println("查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
System.out.println("folderDocId:"+folderDocId) ;
String ptIds = hit.getSource().get("ptIds")+"";
System.out.println("ptIds:"+ptIds) ;
String dtIds = hit.getSource().get("dtIds")+"";
System.out.println("dtIds:"+dtIds) ;
String terms = hit.getSource().get("terms")+"";
System.out.println("terms:"+terms) ;
}
}
}
/**
* 执行搜索
* @param queryBuilder
* @param indexname
* @param type
* @return
*/
public static void hasChildSearcher(QueryBuilder queryBuilder, String indexname, String type){
SearchResponse searchResponse = client.prepareSearch(indexname)
.setQuery(queryBuilder)
.execute()
.actionGet();
SearchHits hits = searchResponse.getHits() ;
System.out.println("查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
System.out.println("folderDocId:"+folderDocId) ;
}
}
}
public static void main(String[] args) throws IOException {
String link = "http://club.autohome.com.cn/bbs/brand-58-c-433-100.htm" ;
ArticleBean articleBean = new ArticleBean();
articleBean.setContent("测试我的文章内容123");
articleBean.setTitle("这是我的文章标题");
articleBean.setAuthorName("付金山");
articleBean.setLink(link) ;
articleBean.setPublishDate(DateUtil.date2String(new Date())) ;
articleBean.setInputTime(DateUtil.date2String(new Date())) ;
String id = SecurityUtil.SHA1(link);
articleBean.setSysId(id);
String projectIds = "[{\"projectId\":27607},{\"projectId\":27605},{\"projectId\":27606}]" ;
net.sf.json.JSONArray projectJsonArray = new net.sf.json.JSONArray() ;
if(projectIds!=null && !projectIds.equals("")){
projectJsonArray = net.sf.json.JSONArray.fromObject(projectIds) ;
}
articleBean.setProjectIds(projectJsonArray) ;
List<ArticleBean> objects= new ArrayList<ArticleBean>() ;
objects.add(articleBean) ;
new ElasticSearchUtils().bulkBuilder(objects, "article", "article") ;
// ElasticSearchUtils.prepareIndex() ;
// ElasticSearchUtils.bulkProcess() ;
// ElasticSearchUtils.bulkBuilder() ;
// ElasticSearchUtils.updateIndexRequest(); //更新索引
/*
* https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child-mapping.html
* http://sense.qbox.io/gist/73f6d2f347a08bfe0c254a977a4a05a68d2f3a8d
* */
/**
XContentBuilder cdoc=XContentFactory.jsonBuilder().startObject().field("b_num_prop",1).field("b_str_prop","部门1").endObject();
IndexResponse cresponse = client.prepareIndex("company", "branch").setSource(cdoc).setId("1").execute().actionGet();
System.out.println("branch:"+cresponse.getId()) ;
XContentBuilder edoc=XContentFactory.jsonBuilder().startObject().field("_parent",1).field("e_child_num",1).field("e_child_str","工号1").endObject();
IndexResponse eresponse = client.prepareIndex("company", "employee").setSource(edoc).setId("1").execute().actionGet();
System.out.println("employee:"+eresponse.getId()) ;
**/
/** 建立父子关联的索引
List<ESDocument> tweets = new ArrayList<ESDocument>() ;
tweets.add(ESDocument.arrayTweetDocument(message)) ;
if(tweets!=null && tweets.size()>0){
BulkRequestBuilder bulkRequest = client.prepareBulk();
for(ESDocument tweet:tweets){
String tweeString = tweet.toString() ;
String pMessage = ESDocument.parseParentDocument(tweeString).toString() ;
System.out.println("pMessage:"+pMessage) ;
String cMessage = ESDocument.parseChildDocument(tweeString).toString() ;
System.out.println("cMessage:"+cMessage) ;
IndexRequestBuilder indexRequest = client.prepareIndex("blog", "text").setSource(pMessage);
bulkRequest.add(indexRequest);
indexRequest = client.prepareIndex("blog", "index").setSource(cMessage).setParent(tweet.getFolderDocId());
bulkRequest.add(indexRequest);
}
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
System.out.println(bulkResponse.buildFailureMessage());
}
}
**/
/**普通查询
QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("blogId", "3822866355643510"));
// QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("title", "胆小鬼"));
// QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.queryStringQuery("ptIds.level:2")); //数组查询
System.out.println(queryBuilder.toString()) ;
ElasticSearchUtils.searcher(queryBuilder, "alert", "index") ;
**/
/** 查询根据子类查询,返回父类结果
QueryBuilder queryBuilder = QueryBuilders.hasChildQuery("indicators", QueryBuilders.termQuery("blogId","1ee526c4af7372ff04bd4e1d6e4cf872ed6b11a7")) ;
System.out.println(queryBuilder.toString()) ;
SearchResponse searchResponse = client.prepareSearch("blog").setTypes("blog").setQuery(queryBuilder).execute().actionGet() ;
SearchHits hits = searchResponse.getHits() ;
System.out.println("查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
String campaignId = hit.getSource().get("campaignId")+"";
String polar = hit.getSource().get("polar")+"";
String view = hit.getSource().get("view")+"";
System.out.println("folderDocId:"+folderDocId) ;
System.out.println("campaignId:"+campaignId) ;
System.out.println("polar:"+polar) ;
System.out.println("view:"+view) ;
}
}
**/
/** 查询根据父类查询,返回子类结果
QueryBuilder queryBuilder = QueryBuilders.hasParentQuery("text", QueryBuilders.boolQuery().must(QueryBuilders.queryStringQuery("terms.attr:67436545"))) ;
System.out.println(queryBuilder.toString()) ;
SearchResponse searchResponse = client.prepareSearch("blog").setTypes("index").setQuery(queryBuilder).execute().actionGet() ;
SearchHits hits = searchResponse.getHits() ;
System.out.println("查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
String campaignId = hit.getSource().get("campaignId")+"";
String polar = hit.getSource().get("polar")+"";
String view = hit.getSource().get("view")+"";
System.out.println("folderDocId:"+folderDocId) ;
System.out.println("campaignId:"+campaignId) ;
System.out.println("polar:"+polar) ;
System.out.println("view:"+view) ;
}
}
**/
/** 查询根据子类查询,返回父和子类结果 方法一: 获取总数为2
QueryBuilder queryBuilder = QueryBuilders.indicesQuery(QueryBuilders.termQuery("blogId","3903007903499940"), "indicators") ;
System.out.println(queryBuilder.toString()) ;
SearchResponse searchResponse = client.prepareSearch("blog").setQuery(queryBuilder).execute().actionGet() ;
SearchHits hits = searchResponse.getHits() ;
System.out.println("查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
String campaignId = hit.getSource().get("campaignId")+"";
String polar = hit.getSource().get("polar")+"";
String view = hit.getSource().get("view")+"";
System.out.println("folderDocId:"+folderDocId) ;
System.out.println("campaignId:"+campaignId) ;
System.out.println("polar:"+polar) ;
System.out.println("view:"+view) ;
}
}
*/
/** 查询根据子类查询,返回父和子类结果 方法二: 获取总数为1
QueryBuilder queryBuilder = QueryBuilders.hasChildQuery("indicators", QueryBuilders.termQuery("blogId","1ee526c4af7372ff04bd4e1d6e4cf872ed6b11a7")).innerHit(new QueryInnerHitBuilder()) ; ;
System.out.println(queryBuilder.toString()) ;
SearchResponse searchResponse = client.prepareSearch("blog").setTypes("blog").setQuery(queryBuilder).execute().actionGet() ;
SearchHits hits = searchResponse.getHits() ;
System.out.println("blog indicators 查询到记录数=" + hits.getTotalHits());
SearchHit[] searchHists = hits.getHits();
if(searchHists.length>0){
for(SearchHit hit:searchHists){
System.out.println("source:"+hit.getSource().toString()) ;
System.out.println("getInnerHits:"+hit.getInnerHits().toString()) ;
String folderDocId = hit.getSource().get("folderDocId")+"";
String campaignId = hit.getSource().get("campaignId")+"";
System.out.println("folderDocId:"+folderDocId) ;
System.out.println("campaignId:"+campaignId) ;
Map<String, SearchHits> innerHits = hit.getInnerHits();
SearchHits innerHit = innerHits.get("indicators");
System.out.println("indicators 查询到记录数=" + innerHit.getTotalHits());
SearchHit[] searchinnerHits = innerHit.getHits();
if(searchinnerHits.length>0){
for(SearchHit inner:searchinnerHits){
String polar = inner.getSource().get("polar")+"";
String view = inner.getSource().get("view")+"";
System.out.println("polar:"+polar) ;
System.out.println("view:"+view) ;
}
}
}
}
**/
/**组合分组查询
SearchResponse sr = client.prepareSearch("blog").setTypes("blog").setQuery(QueryBuilders.matchAllQuery())
.addAggregation(AggregationBuilders.terms("1").field("mediaType"))
.execute().actionGet();
org.elasticsearch.search.aggregations.bucket.terms.Terms a = sr.getAggregations().get("1");
for(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket bk:a.getBuckets()){
System.out.println("类型: "+bk.getKey()+" 分组统计数量 "+bk.getDocCount()+" ");
}
System.out.println("聚合数量:"+a.getBuckets().size());
**/
/**组合分组查询 http://www.nosqldb.cn/1393917706416.html
SearchResponse response = client.prepareSearch("blog").setTypes("blog")
.addAggregation(AggregationBuilders.terms("terms")
.field("mediaType"))
.execute().actionGet();
Terms terms = response.getAggregations().get("terms");
for(org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket b:terms.getBuckets()){
System.out.println("filedname:"+b.getKey()+"docCount:"+b.getDocCount());
}
**/
/** facet查询 http://www.chepoo.com/elasticsearch-facet-search-example.html
String eSql = "*:*" ;
QueryBuilder queryBuilder = QueryBuilders.queryStringQuery(eSql) ;
SearchResponse searchResponse = client.prepareSearch("blog")
.setTypes("blog")
.addFacet(FacetBuilders.termsFacet("termFacet").fields("mediaType"))
.setQuery(queryBuilder)
.execute().actionGet() ;
TermsFacet f = (TermsFacet) searchResponse.getFacets().facetsAsMap().get("termFacet");
f.getTotalCount(); // Total terms doc count
f.getOtherCount(); // Not shown terms doc count
f.getMissingCount(); // Without term doc count
for (TermsFacet.Entry entry : f) {
System.out.println(entry.getTerm() +" count:"+entry.getCount());
//entry.getTerm()为catid,分类id
//entry.getCount()为该分类下的数量
}
**/
}
}
- 浏览: 397074 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (311)
- 网站开发及性能优化 (1)
- JQUERY滚动加载 (1)
- 网络编辑 (1)
- redis (2)
- memcache (4)
- mongodb (5)
- kafka (7)
- apache (3)
- Nexus (2)
- 操作系统 (21)
- JDK (2)
- MyEclipse (11)
- SVN (4)
- Tomcat (3)
- Solr (4)
- CENTOS (5)
- ubuntu (2)
- 新浪微博api (1)
- elasticsearch (60)
- java (28)
- MAC (6)
- Lucene (4)
- Linux (14)
- mysql (6)
- XenCenter (1)
- ext (3)
- spring (6)
- oracle (4)
- tsp (1)
- JForum (1)
- jms (1)
- CAS (1)
- jquery (6)
- freemarker (2)
- 项目管理 (5)
- CSS (3)
- 事务管理 (1)
- js (3)
- 分词 (1)
- 分词器 (1)
- oauthToken (1)
- hadoop (8)
- spark (1)
- cache (1)
- unicode (1)
- 正则表达式 (1)
- google (1)
- Postfix (4)
- windows (3)
- 搜索引擎 (1)
- notepad (1)
- nginx (1)
- outlook (1)
- Fiddler (2)
- Shadowsocks (0)
- github (1)
- 算法 (4)
- zabbix (1)
- office (2)
- maven (8)
- TeamView (1)
- csv (1)
- mikrotik (1)
- DELL (1)
- USVN (2)
- mybatis (3)
- vue (1)
- python (1)
- zxing (2)
- Intellij idea (0)
- IDEA (2)
- http (2)
- JWT (1)
- CAP (1)
- Nacos (1)
- OpenFeign (1)
- SpringCloud (1)
- feign (1)
- springboot (2)
- skywalking (1)
- 微服务 (2)
- 部署 (1)
- bootstrap (1)
最新评论
-
xam_sunny:
用楼主的第一种方法解决了乱码问题,谢谢分享。
spring 中文乱码 -
lzq570:
...
freemarker中分页
- esJson.rar (3.1 KB)
- 下载次数: 0
发表评论
-
elasticsearch-env行116未预期的符号附近有语法错误
2020-07-04 15:11 735> 第一次解决方式(): bash 3.0后,she ... -
Elasticsearch启动、停止脚本
2020-07-04 15:00 700构建Elasticsearch启动脚本 start_es ... -
Elasticsearch搜索类型(query type)详
2016-08-04 12:05 661es在查询时,可以指定 ... -
elasticsearch游标查询所有数据
2016-08-04 10:47 2059在Elasticsearch中找一个 ... -
Elasticsearch安装与测试验证详解
2016-07-29 18:05 821什么是Elasticsearch? 【百科】Elasti ... -
Shard数调优(ElasticSearch性能)
2016-07-27 18:12 1973摘要 当创建一个索引的时候,我们经常会面对一个问题:要为索 ... -
Elasticsearch的存储模型和读写操作
2016-07-27 15:46 473剖析Elasticsearch集群系列涵盖了当今最流行的分布 ... -
亿级规模的 Elasticsearch 优化实战
2016-07-27 15:33 886Elasticsearch 的基本信息大致如图所示,这里就不 ... -
Elasticsearch 架构以及源码概览
2016-07-22 18:18 712Elasticsearch 是最近两年异军突起的一个兼有搜 ... -
Elasticsearch模块功能之-路由(routing)
2016-07-22 15:44 713索引分片分配能够控制索引分片在节点上怎么分布,那对于具体的文 ... -
elasticsearch通用API,多数据源,分组
2016-07-12 13:53 2916公司项目大规模使用elasticsearch,封装了统一的e ... -
Elasticsearch过滤与聚合的先后顺序java实现
2016-07-07 10:48 4447一、Elasticsearch的聚合 ES的聚合相当于关系 ... -
ElasticSearch Java api 详解_V1.0
2016-07-07 10:23 815原英文文档:http://www.elasticsearc ... -
Elasticsearch head插件介绍
2016-06-30 16:31 1929datasize: 121Mi (242Mi)docs: 1 ... -
Elasticsearch 1.7 热更新
2016-06-07 14:42 1308搜索是一个需要不停改进的项目,有时我们需要更新分词插件,有时 ... -
Elasticsearch 搜索服务器全集群升级版本并重启
2016-05-28 21:36 749Elasticsearch 搜索服务器需要一个完整的集群重启 ... -
集群临时重启
2016-05-28 21:17 611集群节点临时重启当修改配置时可能需要重启集群才生效,或者集群发 ... -
elasticsearch之节点重启
2016-05-24 13:22 981Elasticsearch节点重启时背后发 ... -
elasticsearch如何安全重启节点
2016-05-24 11:58 899elasticsearch集群,有时候可能需要修改配置 ... -
Elasticsearch 合理内存分配
2016-05-03 22:45 770Elasticsearch默认安装后设置的内存是1GB,对于 ...
相关推荐
在这个特定的场景中,我们关注的是一个自定义的"elasticsearch join 插件",这个插件是基于Elasticsearch的parent-child关系进行改进的,新增了字段join功能。 在Elasticsearch原生的parent-child关系中,数据被...
Boost the searching capabilities of your system through synonyms, multilingual data handling, nested objects and parent-child documents Deep dive into the world of data aggregation and data analysis ...
分布式搜索是现代大数据处理的关键技术之一,而Elasticsearch作为其中的佼佼者,因其高效、灵活和可扩展性而广泛应用于各种场景。本篇将深入探讨Elasticsearch的基础知识,涵盖其核心概念、环境搭建、配置管理以及...
09-6 -nested_vs_parent_child.avi 09-7 -reindex.avi 09-8 其他建议.avi 10-1 生产环境部署建议.avi 10-2 写性能优化.avi 10-3 读性能优化.avi 10-4 如何设定shard数.avi 10-5 xpack监控功能介绍.avi 11-1 入门及...
Elasticsearch Grails 插件 - 示例应用Elasticsearch Grails 插件的示例应用程序。 插件主页由 Noam Y. Tenne 维护并托管在 。为什么? 如果您习惯了 grails 但从未使用过 ,那么安装插件后您可能会有点迷茫。 ...
- **parent-child文档关系处理**:讲解如何在Elasticsearch中建立和查询parent-child文档关系,适用于某些特定的数据模型。 - **脚本使用**:介绍如何使用脚本来执行复杂的逻辑操作,如动态计算字段值等。 #### 第...
ElasticSearch是一款基于Lucene构建的开源搜索引擎,它提供了分布式的全文搜索功能,常用于大数据量的实时搜索场景。ElasticSearch 5.6版的Java API中文文档是针对Java开发者使用ElasticSearch的指导手册,它不仅...
GET /parent-index/_left{ "query": { "match": { "productName": "상품 조회" } }, "from": 0, "size": 10000, "join": { "index": "child-index", "parent": "bundleKey", "child": "bundleKey", "query": { "mat...
jQuery1.2 API 中文版折叠展开折叠全部展开全部 英文说明 核心jQuery 核心函数 jQuery(expression,[context]) jQuery(expression,[context]) 这个函数接收一个包含 CSS 选择器的字符串,然后用这个字符串去匹配一组...
- 有些名词复数形式有特殊变化,例如:child--children,mouse--mice,man--men,woman--women。 通过以上知识点的学习,学生应该能够更熟练地谈论自己的家庭,构建和理解 Family Tree,并掌握如何在句子中正确...
The author has charged in a previous article that child psychotherapy is es- sentially an expensive illusion with regard to the great majority of children referred to private therapists and to ...
- 特殊的不规则变化,如child->children,man->men,woman->women 通过这些知识点的学习,学生能够更熟练地表达和讨论家庭成员,增强语言表达的丰富性和准确性,同时也能增进对中西方家庭文化差异的理解。
parent -> parents;mother -> mothers;father -> fathers;sister -> sisters;brother -> brothers;son -> sons;daughter -> daughters;case -> cases;box -> boxes;card -> cards;family -> families。 ...
1. 名词复数形式:名词变复数有固定规则,如一般情况下加-s(parent -> parents),以s、x、ch、sh结尾的加-es(bus -> buses),以元音+y结尾的变y为i再加-es(child -> children),不规则名词变化(life -> lives...
console.log('Log from parent constructor'); }, { foo: function() { return 42; } }); var ChildClass = CG(function() { console.log('Log from child constructor'); }, { getMeaning: function() { ...
- 规则变化:一般情况下,名词在词尾加 `-s` 或 `-es` 形成复数,例如 `book -> books`。 - 不规则变化:某些名词有特殊的复数形式,如 `man -> men`, `child -> children`。 - 复合名词变复数:如果名词由两个词...
div.parent div.child { /* 选择父div下的子div */ } /* 使用逻辑运算符 or */ .button.primary, .button.secondary { /* 选择类为primary或secondary的按钮 */ } ``` 通过学习和分析这个项目的源代码,你可以...
在这个例子中,`Child`类通过`Parent.call(this, name)`继承了`Parent`类的属性,同时`Child.prototype`指向了`Parent.prototype`的一个新副本,从而继承了`Parent`类的方法。这种方式既保留了父类的实例属性,又...
Child.prototype = Object.create(Parent.prototype); Child.prototype.constructor = Child; var child = new Child(); console.log(child.name); // 输出 "parent" ``` 2. **构造函数继承**:通过在子类...