本文整理匯總了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);
}