Fixed issue related to nested objects

This commit is contained in:
Mohsin Husen
2013-02-01 12:37:03 +00:00
parent 8d65d92b4a
commit 92a18bd0fb
14 changed files with 184 additions and 12 deletions

View File

@@ -101,7 +101,7 @@ class CriteriaQueryProcessor {
((BoolQueryBuilder) query).should(fieldQuery(fieldName, item));
}
break;
}
}
return query;
}

View File

@@ -21,6 +21,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
@@ -234,6 +235,8 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
}
private ElasticsearchPersistentEntity 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 elasticsearchConverter.getMappingContext().getPersistentEntity(clazz);
}

View File

@@ -46,12 +46,12 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
super(typeInformation);
this.context = new StandardEvaluationContext();
Class<T> clazz = typeInformation.getType();
Assert.isTrue(clazz.isAnnotationPresent(Document.class),
clazz.getSimpleName() + " is not a Document. Make sure the document class is annotated with @Document(indexName=\"foo\")");
Document document = clazz.getAnnotation(Document.class);
Assert.hasText(document.indexName(), " Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
this.indexName = typeInformation.getType().getAnnotation(Document.class).indexName();
this.indexType = hasText(document.type())? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
if(clazz.isAnnotationPresent(Document.class)){
Document document = clazz.getAnnotation(Document.class);
Assert.hasText(document.indexName(), " Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
this.indexName = typeInformation.getType().getAnnotation(Document.class).indexName();
this.indexType = hasText(document.type())? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
}
}
@Override