本文整理汇总了Java中org.springframework.data.elasticsearch.annotations.Document类的典型用法代码示例。如果您正苦于以下问题:Java Document类的具体用法?Java Document怎么用?Java Document使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Document类属于org.springframework.data.elasticsearch.annotations包,在下文中一共展示了Document类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPersistentEntityFor
import org.springframework.data.elasticsearch.annotations.Document; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ElasticsearchPersistentEntity<Object> getPersistentEntityFor(Class clazz) {
Assert.isTrue(clazz.isAnnotationPresent(Document.class), "Unable to identify index name. " + clazz.getSimpleName()
+ " is not a Document. Make sure the document class is annotated with @Document(indexName=\"foo\")");
return (ElasticsearchPersistentEntity<Object>) elasticsearchConverter.getMappingContext().getRequiredPersistentEntity(clazz);
}
示例2: getIndexType
import org.springframework.data.elasticsearch.annotations.Document; //导入依赖的package包/类
/**
* Gets Elasticsearch type
*
* @return Name of Elasticsearch type
*/
default String getIndexType() {
Document document = getUType().getAnnotation(Document.class);
if (document != null) {
return document.type();
} else {
throw new GeneralException("Missing Elasticsearch @Document.type for " + getUType().getSimpleName());
}
}
示例3: getIndexName
import org.springframework.data.elasticsearch.annotations.Document; //导入依赖的package包/类
/**
* Gets Elasticsearch index
*
* @return Name of Elasticsearch index
*/
default String getIndexName() {
Document document = getUType().getAnnotation(Document.class);
if (document != null) {
return document.indexName();
} else {
throw new GeneralException("Missing Elasticsearch @Document.indexName for " + getUType().getSimpleName());
}
}
示例4: setPersistentEntityId
import org.springframework.data.elasticsearch.annotations.Document; //导入依赖的package包/类
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {
if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {
ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
// Only deal with String because ES generated Ids are strings !
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
}
}
}
示例5: isDocument
import org.springframework.data.elasticsearch.annotations.Document; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean isDocument(Class clazz) {
return clazz.isAnnotationPresent(Document.class);
}