Search in sources :

Example 1 with DescribeIndexFieldsResult

use of com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsResult in project nutch by apache.

the class CloudSearchIndexWriter method open.

@Override
public void open(Configuration conf, String name) throws IOException {
    LOG.debug("CloudSearchIndexWriter.open() name={} ", name);
    maxDocsInBatch = conf.getInt(CloudSearchConstants.MAX_DOCS_BATCH, -1);
    buffer = new StringBuffer(MAX_SIZE_BATCH_BYTES).append('[');
    dumpBatchFilesToTemp = conf.getBoolean(CloudSearchConstants.BATCH_DUMP, false);
    if (dumpBatchFilesToTemp) {
        // no more config required
        return;
    }
    String endpoint = conf.get(CloudSearchConstants.ENDPOINT);
    if (StringUtils.isBlank(endpoint)) {
        throw new RuntimeException("endpoint not set for CloudSearch");
    }
    AmazonCloudSearchClient cl = new AmazonCloudSearchClient();
    if (StringUtils.isNotBlank(regionName)) {
        cl.setRegion(RegionUtils.getRegion(regionName));
    }
    String domainName = null;
    // retrieve the domain name
    DescribeDomainsResult domains = cl.describeDomains(new DescribeDomainsRequest());
    Iterator<DomainStatus> dsiter = domains.getDomainStatusList().iterator();
    while (dsiter.hasNext()) {
        DomainStatus ds = dsiter.next();
        if (ds.getDocService().getEndpoint().equals(endpoint)) {
            domainName = ds.getDomainName();
            break;
        }
    }
    // check domain name
    if (StringUtils.isBlank(domainName)) {
        throw new RuntimeException("No domain name found for CloudSearch endpoint");
    }
    DescribeIndexFieldsResult indexDescription = cl.describeIndexFields(new DescribeIndexFieldsRequest().withDomainName(domainName));
    for (IndexFieldStatus ifs : indexDescription.getIndexFields()) {
        String indexname = ifs.getOptions().getIndexFieldName();
        String indextype = ifs.getOptions().getIndexFieldType();
        LOG.info("CloudSearch index name {} of type {}", indexname, indextype);
        csfields.put(indexname, indextype);
    }
    client = new AmazonCloudSearchDomainClient();
    client.setEndpoint(endpoint);
}
Also used : DescribeDomainsResult(com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult) DescribeDomainsRequest(com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest) DescribeIndexFieldsRequest(com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsRequest) IndexFieldStatus(com.amazonaws.services.cloudsearchv2.model.IndexFieldStatus) AmazonCloudSearchClient(com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient) AmazonCloudSearchDomainClient(com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient) DomainStatus(com.amazonaws.services.cloudsearchv2.model.DomainStatus) DescribeIndexFieldsResult(com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsResult)

Aggregations

AmazonCloudSearchDomainClient (com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient)1 AmazonCloudSearchClient (com.amazonaws.services.cloudsearchv2.AmazonCloudSearchClient)1 DescribeDomainsRequest (com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest)1 DescribeDomainsResult (com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult)1 DescribeIndexFieldsRequest (com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsRequest)1 DescribeIndexFieldsResult (com.amazonaws.services.cloudsearchv2.model.DescribeIndexFieldsResult)1 DomainStatus (com.amazonaws.services.cloudsearchv2.model.DomainStatus)1 IndexFieldStatus (com.amazonaws.services.cloudsearchv2.model.IndexFieldStatus)1