Package org.elasticsearch.common.settings.ImmutableSettings

Examples of org.elasticsearch.common.settings.ImmutableSettings.Builder


    clusterName = job.get(ElasticConstants.CLUSTER);

    host = job.get(ElasticConstants.HOST);
    port = job.getInt(ElasticConstants.PORT, 9300);

    Builder settingsBuilder = ImmutableSettings.settingsBuilder().classLoader(
        Settings.class.getClassLoader());

    BufferedReader reader = new BufferedReader(
        job.getConfResourceAsReader("elasticsearch.conf"));
    String line;
    String parts[];

    while ((line = reader.readLine()) != null) {
      if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
        line.trim();
        parts = line.split("=");

        if (parts.length == 2) {
          settingsBuilder.put(parts[0].trim(), parts[1].trim());
        }
      }
    }

    if (StringUtils.isNotBlank(clusterName))
      settingsBuilder.put("cluster.name", clusterName);

    // Set the cluster name and build the settings
    Settings settings = settingsBuilder.build();

    // Prefer TransportClient
    if (host != null && port > 1) {
      client = new TransportClient(settings)
          .addTransportAddress(new InetSocketTransportAddress(host, port));
View Full Code Here


  public void open(JobConf job, String name) throws IOException {
    clusterName = job.get(ElasticConstants.CLUSTER);
    host = job.get(ElasticConstants.HOST);
    port = job.getInt(ElasticConstants.PORT, -1);

    Builder settingsBuilder = ImmutableSettings.settingsBuilder();
   
    BufferedReader reader = new BufferedReader(job.getConfResourceAsReader("elasticsearch.conf"));
    String line;
    String parts[];

    while ((line = reader.readLine()) != null) {
      if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
        line.trim();
        parts = line.split("=");

        if (parts.length == 2) {
          settingsBuilder.put(parts[0].trim(), parts[1].trim());
        }
      }
    }

    // Set the cluster name and build the settings
    Settings settings = settingsBuilder.put("cluster.name", clusterName).build();
   
    // Prefer TransportClient
    if (host != null && port > 1) {
      client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(host, port));
    } else if (clusterName != null) {
View Full Code Here

      numShards++;
      numShards *= 2;
      numShards++; // (somewhat arbitrary equation, 1 shard -> 5 was pretty much the justification...)
    }   
   
    Builder localSettingsEvent = ImmutableSettings.settingsBuilder();
    localSettingsEvent.put("number_of_shards", numShards).put("number_of_replicas", 0);
    ElasticSearchManager customIndex = IndexManager.createIndex(indexToBuild, "custom", false, null, null, localSettingsEvent);
      // (don't need to set the mapping - that happens automatically because I've registered a template)
   
    return customIndex;   
  }//TESTED (basic functionality)
View Full Code Here

     
      if (!pm.getAggregationDisabled()) {
       
        boolean languageNormalization = pm.getNormalizeEncoding();
       
        Builder localSettingsEvent = ImmutableSettings.settingsBuilder();
        localSettingsEvent.put("number_of_shards", 1).put("number_of_replicas", 0);
        localSettingsEvent.put("index.analysis.analyzer.suggestAnalyzer.tokenizer", "standard");
        if (languageNormalization) {
          localSettingsEvent.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "icu_normalizer","icu_folding","standard","lowercase");
        }
        else {
          localSettingsEvent.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "standard","lowercase");         
        }
 
        Builder localSettingsGaz = ImmutableSettings.settingsBuilder();
        localSettingsGaz.put("number_of_shards", 1).put("number_of_replicas", 0);
        localSettingsGaz.put("index.analysis.analyzer.suggestAnalyzer.tokenizer", "standard");
        if (languageNormalization) {
          localSettingsGaz.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "icu_normalizer","icu_folding","standard","lowercase");
        }
        else {
          localSettingsGaz.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "standard","lowercase");         
        }
     
        //event feature
        String eventGazMapping = new Gson().toJson(new AssociationFeaturePojoIndexMap.Mapping(), AssociationFeaturePojoIndexMap.Mapping.class)
        ElasticSearchManager eventIndex = IndexManager.createIndex(AssociationFeaturePojoIndexMap.indexName_, null, false, null, eventGazMapping, localSettingsEvent);
View Full Code Here

     
        int nShards = bSystemGroup? 10 : 5 ; // (system group is largest)
       
        // Remove the alias, in case it exists:
        // Then create an index with this name:
        Builder localSettingsGroupIndex = ImmutableSettings.settingsBuilder();
        localSettingsGroupIndex.put("number_of_shards", nShards).put("number_of_replicas", nPreferredReplicas)
        if (languageNormalization) {
          localSettingsGroupIndex.put("index.analysis.analyzer.default.tokenizer","standard");
          localSettingsGroupIndex.putArray("index.analysis.analyzer.default.filter", "icu_normalizer","icu_folding","standard","lowercase","stop");
        }//TESTED

        ElasticSearchManager docIndex = IndexManager.createIndex(sGroupIndex, DocumentPojoIndexMap.documentType_, false, null, docMapping, localSettingsGroupIndex);
        if (null == docIndex) { // index has already been referenced, hence createIndex returns null
          docIndex = IndexManager.getIndex(sGroupIndex);
        }
        if (bClearIndex) {
          docIndex.deleteMe();
          docIndex = IndexManager.createIndex(sGroupIndex, DocumentPojoIndexMap.documentType_, false, null, docMapping, localSettingsGroupIndex);
        }
        if (null != docIndex) {
          try {
            docIndex.pingIndex(); // (wait until it's created itself)
          }
          catch (Exception e) {} // (just make sure this doesn't die horribly)
        }
        else {
          docIndex = IndexManager.getIndex(sGroupIndex);
        }
        if (null != docIndex) { // should always be true
          docIndex.createAlias(sAliasIndex);
          docIndex.closeIndex();
        }
      }
      else if (!bParentsOnly) { // A sub-index of a parent      
       
        parentCommunityId = getRootCommunity(parentCommunityId);
       
        if (null != parentCommunityId) {
          String parentCommunityIdStr = parentCommunityId.toString();
         
          String sParentGroupIndex = new StringBuffer("doc_").append(new ObjectId(parentCommunityIdStr).toString()).toString();
          ElasticSearchManager docIndex = IndexManager.getIndex(sParentGroupIndex);
         
          //DEBUG (alias corruption)
//          if (null == _aliasInfo) {
//            ClusterStateResponse clusterState = docIndex.getRawClient().admin().cluster().state(new ClusterStateRequest()).actionGet();
//            _aliasInfo = CrossVersionImmutableMapOfImmutableMaps.getAliases(clusterState.getState().getMetaData());
//          }
//          else {
//            if (_aliasInfo.containsKey(sGroupIndex)) { // has no aliases, we're not good
//              return;
//            }
//            else {
//              //DEBUG
//              System.out.println("Alias " + sGroupIndex + " has no aliases (but should)");           
//              ElasticSearchManager docIndex2 = IndexManager.getIndex(sGroupIndex);
//              docIndex2.deleteMe();
//            }
//          }
       
          docIndex.createAlias(sGroupIndex); // for indexing
            // (this is going to be tricky when the functionality is fully implemented
            //  because it will need to handle the parent index splitting)
          docIndex.createAlias(sAliasIndex); // for queries
          docIndex.closeIndex();
          // (do nothing on delete - that will be handled at the parent index level)
        }
      }
      //TESTED (parents, children, and personal + docs_ aliases)
    }
    else { // (Personal group)
      // Just create the dummy index, no different to getting it in practice
      Builder localSettingsGroupIndex = ImmutableSettings.settingsBuilder();
      localSettingsGroupIndex.put("number_of_shards", 1).put("number_of_replicas", 0); // (ie guaranteed to be local to each ES node) 
      ElasticSearchManager dummyGroupIndex = IndexManager.createIndex(DocumentPojoIndexMap.dummyDocumentIndex_, DocumentPojoIndexMap.documentType_, false, null, docMapping, localSettingsGroupIndex);
      if (null == dummyGroupIndex) {
        dummyGroupIndex = IndexManager.getIndex(DocumentPojoIndexMap.dummyDocumentIndex_);
      }     
     
View Full Code Here

        //(also deletes the child index - same index, different type)

        // Create the index if necessary
        String sMapping = new Gson().toJson(new DocumentPojoIndexMap.Mapping(), DocumentPojoIndexMap.Mapping.class);

        Builder localSettings = ImmutableSettings.settingsBuilder();
        localSettings.put("number_of_shards", 10).put("number_of_replicas", 2);     
       
        System.out.println("Creating index..." + sMapping);
        elasticManager = ElasticSearchManager.createIndex
                  (indexName, null, false,
                      sElasticHost + ":" + sElasticPort,
View Full Code Here

    //elasticManager = ElasticSearchManager.getIndex(indexName);
    //elasticManager.deleteMe();
   
    // Create the index if necessary
    String sMapping = new Gson().toJson(new EntityFeaturePojoIndexMap.Mapping(), EntityFeaturePojoIndexMap.Mapping.class);
    Builder localSettings = ImmutableSettings.settingsBuilder();
    localSettings.put("number_of_shards", 1).put("number_of_replicas", 0);     
    localSettings.put("index.analysis.analyzer.suggestAnalyzer.tokenizer", "standard");
    localSettings.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "standard", "lowercase");
   
    elasticManager = ElasticSearchManager.createIndex(indexName, null, false,  null, sMapping, localSettings);
   
    // Get the index (necessary if already created)
    if (null == elasticManager)
View Full Code Here

    //elasticManager = ElasticSearchManager.getIndex("association_index");
    //elasticManager.deleteMe();
   
    // Create the index if necessary
    String sMapping = new Gson().toJson(new AssociationFeaturePojoIndexMap.Mapping(), AssociationFeaturePojoIndexMap.Mapping.class);
    Builder localSettings = ImmutableSettings.settingsBuilder();
    localSettings.put("number_of_shards", 1).put("number_of_replicas", 0);     
    localSettings.put("index.analysis.analyzer.suggestAnalyzer.tokenizer", "standard");
    localSettings.putArray("index.analysis.analyzer.suggestAnalyzer.filter", "standard", "lowercase");
   
    elasticManager = ElasticSearchManager.createIndex("association_index", null, false, null, sMapping, localSettings);
   
    // Get the index (necessary if already created)
    if (null == elasticManager)
View Full Code Here

       
        // increase maxClauseCount for friend search ... not necessary
        // http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_a_TooManyClauses_exception.3F
//        BooleanQuery.setMaxClauseCount(100000);

        Builder settings = ImmutableSettings.settingsBuilder();
//                put("network.host", "127.0.0.1").
//                //                put("network.bindHost", "127.0.0.0").
//                //                put("network.publishHost", "127.0.0.0").
//                put("index.number_of_shards", 16).
//                put("index.number_of_replicas", 1);

        if (testing) {
            settings.put("gateway.type", "none");
            // default is local
            // none means no data after node restart!
            // does not work when transportclient connects:
//                put("gateway.type", "fs").
//                put("gateway.fs.location", homeDir.getAbsolutePath()).
        }

        settings.build();
        NodeBuilder nBuilder = nodeBuilder().settings(settings);
        if (!testing) {
            nBuilder.clusterName(CLUSTER);
        } else {
            nBuilder.local(true);
View Full Code Here

   
    String[] hostPort = hostAndPort.split("[:/]");
    sHostname = hostPort[0];
    sPort = hostPort[1];

    Builder globalSettings = ImmutableSettings.settingsBuilder();
    Settings snode = globalSettings.put("cluster.name", _clusterName).build();
   
    Client client = null;
    TransportClient tmp = null;
    try {
      tmp = new TransportClient(snode);
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.settings.ImmutableSettings.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.