Package org.springframework.data.elasticsearch

Examples of org.springframework.data.elasticsearch.ElasticsearchException


      return null;
    }
    try {
      return entityMapper.mapToObject(source, clazz);
    } catch (IOException e) {
      throw new ElasticsearchException("failed to map source [ " + source + "] to class " + clazz.getSimpleName(), e);
    }
  }
View Full Code Here


    XContentBuilder xContentBuilder = null;
    try {
      xContentBuilder = buildMapping(clazz, persistentEntity.getIndexType(), persistentEntity
          .getIdProperty().getFieldName(), persistentEntity.getParentType());
    } catch (Exception e) {
      throw new ElasticsearchException("Failed to build mapping for " + clazz.getSimpleName(), e);
    }
    return putMapping(clazz, xContentBuilder);
  }
View Full Code Here

    Map mappings = null;
    try {
      mappings = client.admin().indices().getMappings(new GetMappingsRequest().indices(indexName).types(type))
          .actionGet().getMappings().get(indexName).get(type).getSourceAsMap();
    } catch (Exception e) {
      throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName + " type : " + type + " " + e.getMessage());
    }
    return mappings;
  }
View Full Code Here

      Map<String, String> failedDocuments = new HashMap<String, String>();
      for (BulkItemResponse item : bulkResponse.getItems()) {
        if (item.isFailed())
          failedDocuments.put(item.getId(), item.getFailureMessage());
      }
      throw new ElasticsearchException(
          "Bulk indexing has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages ["
              + failedDocuments + "]", failedDocuments
      );
    }
  }
View Full Code Here

        }
        indexRequestBuilder.setSource(resultsMapper.getEntityMapper().mapToString(query.getObject()));
      } else if (query.getSource() != null) {
        indexRequestBuilder = client.prepareIndex(indexName, type, query.getId()).setSource(query.getSource());
      } else {
        throw new ElasticsearchException("object or source is null, failed to index the document [id: " + query.getId() + "]");
      }
      if (query.getVersion() != null) {
        indexRequestBuilder.setVersion(query.getVersion());
        indexRequestBuilder.setVersionType(EXTERNAL);
      }

      if (query.getParentId() != null) {
        indexRequestBuilder.setParent(query.getParentId());
      }

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

        try {
            XContentBuilder xContentBuilder = buildMapping(clazz, persistentEntity.getIndexType(), persistentEntity.getIdProperty().getFieldName());
            return requestBuilder.setSource(xContentBuilder).execute().actionGet().acknowledged();
        } catch (Exception e) {
            throw new ElasticsearchException("Failed to build mapping for " + clazz.getSimpleName() , e);
        }
    }
View Full Code Here

            Map<String, String> failedDocuments = new HashMap<String, String>();
            for (BulkItemResponse item : bulkResponse.items()) {
                if (item.failed())
                    failedDocuments.put(item.getId(), item.failureMessage());
            }
            throw new ElasticsearchException("Bulk indexing has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages [" + failedDocuments+"]", failedDocuments);
        }
    }
View Full Code Here

                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

            return null;
        }
        try {
            return objectMapper.readValue(source, clazz);
        } catch (IOException e) {
            throw new ElasticsearchException("failed to map source [ " + source + "] to class " + clazz.getSimpleName() , e);
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.elasticsearch.ElasticsearchException

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.