Search in sources :

Example 1 with ElasticsearchPartQuery

use of org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery in project spring-data-elasticsearch by spring-projects.

the class ElasticsearchPartQueryTests method getQueryBuilder.

private String getQueryBuilder(String methodName, Class<?>[] parameterClasses, Object[] parameters) throws NoSuchMethodException {
    Method method = SampleRepository.class.getMethod(methodName, parameterClasses);
    ElasticsearchQueryMethod queryMethod = new ElasticsearchQueryMethod(method, new DefaultRepositoryMetadata(SampleRepository.class), new SpelAwareProxyProjectionFactory(), converter.getMappingContext());
    ElasticsearchPartQuery partQuery = new ElasticsearchPartQuery(queryMethod, operations);
    CriteriaQuery criteriaQuery = partQuery.createQuery(new ParametersParameterAccessor(queryMethod.getParameters(), parameters));
    SearchSourceBuilder source = new RequestFactory(converter).searchRequest(criteriaQuery, Book.class, IndexCoordinates.of("dummy")).source();
    return source.toString();
}
Also used : SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) ParametersParameterAccessor(org.springframework.data.repository.query.ParametersParameterAccessor) ElasticsearchQueryMethod(org.springframework.data.elasticsearch.repository.query.ElasticsearchQueryMethod) CriteriaQuery(org.springframework.data.elasticsearch.core.query.CriteriaQuery) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) ElasticsearchPartQuery(org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery) ElasticsearchQueryMethod(org.springframework.data.elasticsearch.repository.query.ElasticsearchQueryMethod) Method(java.lang.reflect.Method) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder)

Aggregations

Method (java.lang.reflect.Method)1 SearchSourceBuilder (org.elasticsearch.search.builder.SearchSourceBuilder)1 CriteriaQuery (org.springframework.data.elasticsearch.core.query.CriteriaQuery)1 ElasticsearchPartQuery (org.springframework.data.elasticsearch.repository.query.ElasticsearchPartQuery)1 ElasticsearchQueryMethod (org.springframework.data.elasticsearch.repository.query.ElasticsearchQueryMethod)1 SpelAwareProxyProjectionFactory (org.springframework.data.projection.SpelAwareProxyProjectionFactory)1 DefaultRepositoryMetadata (org.springframework.data.repository.core.support.DefaultRepositoryMetadata)1 ParametersParameterAccessor (org.springframework.data.repository.query.ParametersParameterAccessor)1