一、首先介绍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. mui项目中如何使用原生JavaScript代替jquery来操作dom 转自【B5教程网】:http://www.bcty365.com/content-146-3661-1.html

    最近在用mui写页面,当然了在移动App里引入jq或zepto这些框架,肯定是极不理性的.原生JS挺简单,为何需要jq?jq的成功当时是因为ie6.7.8.9.10.chrome.ff这些浏览器不兼容 ...

  2. 总结移动安全的测试点及详解allowbackup漏洞

    一.移动应用APP可能面临以下威胁: 木马--二次打包, 病毒--账号窃取, 篡改--资源篡改, 破解--广告植入, 钓鱼--信息劫持  二.移动终端APP安全评估的7个方向: 通信安全,敏感信息安全 ...

  3. python笔记7:日期和时间

    Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 时间间隔是以秒为单位的浮点小数. 每个时间戳都以自从1970年1月1日午夜(历元)经过了多长时间来表示. 时间 ...

  4. html5 canvas 绘制太极图

    <div class="container"> <canvas id="myCanvas" width="400" hei ...

  5. Oracle 11203 + ASM安装 for HP UX

    一,安装前准备 1.创建所需组和用户 /usr/sbin/groupadd -g 1000 oinstall/usr/sbin/groupadd -g 1020 asmadmin/usr/sbin/g ...

  6. NFC读写实例

    package com.sy.nfc.test; import java.io.IOException; import android.nfc.NdefMessage; import android. ...

  7. IIS设置默认主页无效

    服务器系统:Windows server 2008 R2 IIS版本:7.5 IIS中部署一个dotnet framework 3.5的网站应用程序,设置"默认文档"为:index ...

  8. SOUI更新到2.0

    更新: 1.修改uiresbuilder,增加资源ID自动生成功能.包括自动提取所有布局中控件的name,自动生成ID,自动提取字符串表,颜色表.具体使用方式参见下一篇. 2.修改布局中引用字符串的方 ...

  9. linux中find批量删除空文件夹

    空文件夹 列出用find 删除管道即可 find -type d -empty | xargs -n 1 rm -rf 注意最后不能rm -f,这样删不了目录,必须-r

  10. qtranslate

    qtranslate可以帮助用户快速的建立多语言网站平台,qTranslate 插件就是一个功能强大的 WordPress 多语言插件. 它允许用户在配置页添加新的语言.在 URL 结构方面,qTra ...