一、首先介绍lucene涉及到的排序过程

1.1、如何自定义排序对象

你可以自定义collector对象;

亦可以自定义comparator对象;

可以自定义scoredoc对象,决定如何处理结果集合;

1.2、这几种自定义之间有何区别?

自定义collector和comparator有什么区别呢????????

Besides building your own Collector to customize how the results are stored and sorted, another way to customize results sorting is to implement your own FieldComparator for SortField. Note that this customization only deals with the sorting aspect of the result set; it does not give you the flexibility to filter out results, as you would have with Collector.

二、ES master slave介绍

master es中的作用就是:it’s the responsability of the master node to allocate the shards equally among the nodes.

requests分为两种:index requests和 search requests;两种请求可以落到集群任何一台机器。

》》然后对于TransportClient本身就是做的round robin形式,

The TransportClient connects remotely to an elasticsearch cluster using the transport module. It does not join the cluster, but simply gets one or more initial transport addresses and communicates with them in round robin fashion on each action

所以你只需要new的时候给定 addresses就好了

 private TransportClient client=null;
Settings settings = Settings.settingsBuilder().put("cluster.name", cluster_name).build();
client = TransportClient.builder().settings(settings).build() ;
for(String host_port:host_ports.split(",")){
String[] hostAndPort=host_port.split(":");
if(hostAndPort.length==2){
String host=hostAndPort[0].trim();
int port=Integer.valueOf(hostAndPort[1].trim());
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
}
}

而其中的配置文件可以是

cluster.name: cluster_name

host.ports: ip1:9300,ip2:9300,ip3:9300

>>对于client的关闭主要是三部曲

client.close();
client.threadPool().shutdown();
client = null;

这个坑的解释是https://discuss.elastic.co/t/correct-way-to-use-transportclient-connection-object/17947/8

三、参考文献

http://blog.trifork.com/2013/10/24/how-to-avoid-the-split-brain-problem-in-elasticsearch/

https://github.com/xuxueli/xxl-search/blob/master/xxl-search-client/src/main/java/com/xxl/search/client/es/ElasticsearchUtil.java

lucene和es总结的更多相关文章

  1. Lucene、ES好文章

    1.lucene4.5源码分析系列:lucene概述 http://blog.csdn.net/liweisnake/article/details/10348969 http://www.cnblo ...

  2. ElasticSearch:Lucene和ElasticSearch

    Lucene的概念: 关于索引 索引(index)和搜索(搜索),在lucene以及es里面索引是一个动作,即插入动作,包括创建索引以及为索引添加文档:所有则是针对索引(添加)的文档按照评分规则进行查 ...

  3. es知识点

    版权声明:本文为博主原创文章,未经博主允许不得转载.转载请务必加上原作者:铭毅天下,原文地址:blog.csdn.net/laoyang360 https://blog.csdn.net/wojius ...

  4. ElasticSearch入门篇Ⅰ --- ES核心知识概括

    C01.什么是Elasticsearch 1.什么是搜索 垂直搜索(站内搜索) 互联网的搜索:电商网站,招聘网站,各种app IT系统的搜索:OA软件,办公自动化软件,会议管理,员工管理,后台管理系 ...

  5. 【Elasticsearch 技术分享】—— 十张图带大家看懂 ES 原理 !明白为什么说:ES 是准实时的!

    前言 说到 Elasticsearch ,其中最明显的一个特点就是 near real-time 准实时 -- 当文档存储在Elasticsearch中时,将在1秒内以几乎实时的方式对其进行索引和完全 ...

  6. 用Jenkins配置自动化构建

     公司培训内容 -------------->记一笔 dubbo 微服务soadiamond-server 配置中心kafka rocketmq消息队列cas-server 单点登录spring ...

  7. 1.ElasticSearch介绍及基本概念

    一.ElasticSearch介绍 一个采用RESTful API标准的高扩展性的和高可用性的实时性分析的全文搜索工具 基于Lucene[开源的搜索引擎框架]构建 ElasticSearch是一个面向 ...

  8. 【转】Elasticsearch学习

    原作者:铭毅天下,原文地址:blog.csdn.net/laoyang360 https://blog.csdn.net/wojiushiwo987/article/details/52244917 ...

  9. Elasticsearch简介和安装对比

    各位小伙伴,又到了本期分享大数据技术的时间,本次给大伙带来的是Elasticsearch这个技术,闲话不多聊,我们开始进入正题. 一.什么是elasticsearch Elasticsearch是一个 ...

随机推荐

  1. (一)Netty源码学习笔记之概念解读

    尊重原创,转载注明出处,原文地址:http://www.cnblogs.com/cishengchongyan/p/6121065.html  博主最近在做网络相关的项目,因此有契机学习netty,先 ...

  2. 获取URL参数值

    function GetQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*) ...

  3. Object-c 类方法和实例方法的区别和联系

    在我学习oc的时候,总是搞不懂什么时候用类方法,什么时候使用实例方法.于是做了如下总结. -表示实例方法: 用实例方法访问 +表示类方法:类方法的对象时类不是实例.多用于创建对象或工具类 什么时候使用 ...

  4. css框架

    框架:如果你想在一个页面里面,嵌入另一个页面,就可以使用框架了. 框架分为两种: 一.iframe标签: 本页面中再嵌入另一个网页. iframe标签:浮动的框架,嵌入页面使用. 可以直接写在body ...

  5. yii 简单依赖注入

    <?phpnamespace app\controllers;use Yii;use yii\di\Container;use yii\di\ServiceLocator;use yii\web ...

  6. 【Java EE 学习 82 下】【MAVEN整合Eclipse】【MAVEN的一些高级概念】

    一.MAVEN整合Eclipse MAVEN是非常优秀,但是总是要开命令行敲命令是比较不爽的,我们已经习惯了使用IDE,所以还有一种将MAVEN整合到Eclipse的方法. 详情查看:http://w ...

  7. 解决一则enq: TX – row lock contention的性能故障

    上周二早上,收到项目组的一封邮件: 早上联代以下时间点用户有反馈EDI导入"假死",我们跟踪了EDI导入服务,服务是正常在跑,可能是处理的慢所以用户感觉是"假死" ...

  8. Go语言 获取get、post参数

    在贴代码之前如果能先理解一下golang http.request的三个属性Form.PostForm.MultipartForm应该能较好的理解代码,下面摘录一下. 以上简要翻译一下: Form:存 ...

  9. RadioGroup 和 ViewPager 绑定 实现切换

    package com.jereh.helloworld.activity.day12; import android.app.Activity; import android.os.Bundle; ...

  10. jquery 回车事件

    简单地记下jquery实现回车事件,代码如下: 全局: $(document).keydown(function(e){ if(e.keyCode==13){ $(".login-li in ...