Package org.elasticsearch.action.index

Examples of org.elasticsearch.action.index.IndexRequestBuilder


    // The index does not exist, let's create it
    if (!versionIndexExists) {
      indexVersion = SearchIndex.INDEX_VERSION;
      logger.debug("Creating version index for site '{}'", site.getIdentifier());
      IndexRequestBuilder requestBuilder = nodeClient.prepareIndex(site.getIdentifier(), VERSION_TYPE, ROOT_ID);
      logger.debug("Index version of site '{}' is {}", site.getIdentifier(), indexVersion);
      requestBuilder = requestBuilder.setSource(VERSION, Integer.toString(indexVersion));
      requestBuilder.execute().actionGet();
    }

    preparedIndices.add(site.getIdentifier());
  }
View Full Code Here


            String indexName = isBlank(query.getIndexName())?
                    retrieveIndexNameFromPersistentEntity(query.getObject().getClass())[0] : query.getIndexName();
            String type = isBlank(query.getType())?
                    retrieveTypeFromPersistentEntity(query.getObject().getClass())[0] : query.getType();

            IndexRequestBuilder indexRequestBuilder = client.prepareIndex(indexName,type,query.getId())
                    .setSource(objectMapper.writeValueAsString(query.getObject()));

            if(query.getVersion() != null){
                indexRequestBuilder.setVersion(query.getVersion());
                indexRequestBuilder.setVersionType(EXTERNAL);
            }
            return indexRequestBuilder;
        } catch (IOException e) {
            throw new ElasticsearchException("failed to index the document [id: " + query.getId() +"]",e);
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.index.IndexRequestBuilder

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.