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);
}
Aggregations