Package com.dotcms.content.elasticsearch.util

Examples of com.dotcms.content.elasticsearch.util.ESClient


    BufferedReader br = null;

    boolean indexExists = indexExists(index);

    Client client = new ESClient().getClient();

    try {
      if (!indexExists) {
        final IndicesAdminClient iac = new ESClient().getClient().admin().indices();

        createIndex(index);
      }

      ZipInputStream zipIn=new ZipInputStream(new FileInputStream(backupFile));
View Full Code Here


   * unclusters an index, including changing the routing to all local
   * @param index
   * @throws IOException
   */
  public  void moveIndexToLocalNode(String index) throws IOException {
        Client client=new ESClient().getClient();
//        String nodeName="dotCMS_" + Config.getStringProperty("DIST_INDEXATION_SERVER_ID");
        String nodeName="dotCMS_" + APILocator.getServerAPI().readServerId();
        UpdateSettingsResponse resp=client.admin().indices().updateSettings(
          new UpdateSettingsRequest(index).settings(
                jsonBuilder().startObject()
View Full Code Here

   * clusters an index, including changing the routing
   * @param index
   * @throws IOException
   */
    public  void moveIndexBackToCluster(String index) throws IOException {
        Client client=new ESClient().getClient();
        int nreplicas=Config.getIntProperty("es.index.number_of_replicas",0);
        UpdateSettingsResponse resp=client.admin().indices().updateSettings(
          new UpdateSettingsRequest(index).settings(
                jsonBuilder().startObject()
                     .startObject("index")
View Full Code Here

  public synchronized CreateIndexResponse createIndex(String indexName, String settings, int shards) throws ElasticSearchException, IOException {

    AdminLogger.log(this.getClass(), "createIndex",
                "Trying to create index: " + indexName + " with shards: " + shards);

        IndicesAdminClient iac = new ESClient().getClient().admin().indices();

    if(shards <1){
      try{
        shards = Integer.parseInt(System.getProperty("es.index.number_of_shards"));
      }catch(Exception e){}
View Full Code Here

    //Seems like the method is not longer used
    // but I still will add the log just in case
        AdminLogger.log(this.getClass(), "createIndex",
                "Trying to create index: " + indexName + " with shards: " + shards);

        IndicesAdminClient iac = new ESClient().getClient().admin().indices();

    if(shards <1){
      try{
        shards = Integer.parseInt(System.getProperty("es.index.number_of_shards"));
      }catch(Exception e){}
View Full Code Here

    /**
     * returns cluster health
     * @return
     */
    public Map<String,ClusterIndexHealth> getClusterHealth() {
        AdminClient client=new ESClient().getClient().admin();

        ClusterHealthRequest req = new ClusterHealthRequest();
        ActionFuture<ClusterHealthResponse> chr = client.cluster().health(req);

        ClusterHealthResponse res  = chr.actionGet();
View Full Code Here

      Map newSettings = new HashMap();
          newSettings.put("index.number_of_replicas", replicas+"");


      UpdateSettingsRequestBuilder usrb = new ESClient().getClient().admin().indices().prepareUpdateSettings(indexName);
      usrb.setSettings(newSettings);
      usrb.execute().actionGet();
    }
   
    AdminLogger.log(this.getClass(), "updateReplicas", "Replicas updated to index: " + indexName);
View Full Code Here

    AdminLogger.log(this.getClass(), "updateReplicas", "Replicas updated to index: " + indexName);
    }

    public void putToIndex(String idx, String json, String id){
     try{
       Client client=new ESClient().getClient();

       IndexResponse response = client.prepareIndex(idx, SiteSearchAPI.ES_SITE_SEARCH_MAPPING, id)
              .setSource(json)
              .execute()
              .actionGet();
View Full Code Here

    public void createAlias(String indexName, String alias) {
        try{
            // checking for existing alias
            if(getAliasToIndexMap(APILocator.getSiteSearchAPI().listIndices()).get(alias)==null) {
                Client client=new ESClient().getClient();
                IndicesAliasesRequest req=new IndicesAliasesRequest();
                req.addAlias(indexName, alias);
                client.admin().indices().aliases(req).actionGet(30000L);
            }
         } catch (Exception e) {
View Full Code Here

    }

    public Map<String,String> getIndexAlias(String[] indexNames) {
        Map<String,String> alias=new HashMap<String,String>();
        try{
            Client client=new ESClient().getClient();
            ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
                    .filterRoutingTable(true)
                    .filterNodes(true)
                    .filteredIndices(indexNames);
            MetaData md=client.admin().cluster().state(clusterStateRequest)
View Full Code Here

TOP

Related Classes of com.dotcms.content.elasticsearch.util.ESClient

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.