• lucene和es总结


    一、首先介绍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

  • 相关阅读:
    java9
    java8
    java7
    java6
    java5
    java4
    java-list-分组
    Termux中安装gcc-7/gfortran-7实操过程,安装成功可以编译Fortran,c/c++
    安卓手机牛逼软件Termux中安装Archlinux,安装Jdk
    c++语言的组合类的使用,用组合类的方法计算两点间距离。
  • 原文地址:https://www.cnblogs.com/amazement/p/6218917.html
Copyright © 2020-2023  润新知