Example usage for com.amazonaws.services.cloudsearchv2.model IndexField getIndexFieldName

List of usage examples for com.amazonaws.services.cloudsearchv2.model IndexField getIndexFieldName

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudsearchv2.model IndexField getIndexFieldName.

Prototype


public String getIndexFieldName() 

Source Link

Document

A string that represents the name of an index field.

Usage

From source file:com.clicktravel.infrastructure.persistence.aws.cloudsearch.manager.CloudSearchInfrastructureManager.java

License:Apache License

private void createCloudSearchDomain(final String domainName,
        final Collection<IndexDefinition> indexDefinitions) {
    final CreateDomainRequest createDomainRequest = new CreateDomainRequest().withDomainName(domainName);
    final CreateDomainResult createDomainResult = cloudSearchClient.createDomain(createDomainRequest);
    if (!createDomainResult.getDomainStatus().getCreated()) {
        throw new IllegalStateException(String.format("Domain with name %s failed to be created", domainName));
    }//w  w  w.j  av  a 2s.c o  m
    logger.debug("CloudSearch domain created: " + domainName);
    final Collection<IndexField> indexFields = indexDefinitionToIndexFieldCollectionMapper
            .map(indexDefinitions);
    for (final IndexField indexField : indexFields) {
        final DefineIndexFieldRequest defineIndexFieldRequest = new DefineIndexFieldRequest()
                .withDomainName(domainName).withIndexField(indexField);
        final DefineIndexFieldResult defineIndexFieldResult = cloudSearchClient
                .defineIndexField(defineIndexFieldRequest);
        if (OptionState.valueOf(defineIndexFieldResult.getIndexField().getStatus()
                .getState()) != OptionState.RequiresIndexDocuments) {
            throw new IllegalStateException(
                    String.format("Index with name %s failed to be created in domain %s",
                            indexField.getIndexFieldName(), domainName));
        }
        logger.debug("CloudSearch index created: " + domainName + "->" + indexField.getIndexFieldName());
    }
    final IndexDocumentsRequest indexDocumentsRequest = new IndexDocumentsRequest().withDomainName(domainName);
    cloudSearchClient.indexDocuments(indexDocumentsRequest);
    logger.debug("CloudSearch index rebuilding started for domain : " + domainName);
}