当前位置: 首页>>代码示例>>Java>>正文


Java Query类代码示例

本文整理汇总了Java中org.springframework.data.solr.repository.Query的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Query类属于org.springframework.data.solr.repository包,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultOperator

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
/**
 * @return value of {@link Query#defaultOperator()} or
 *         {@link org.springframework.data.solr.core.query.Query.Operator#NONE} if not set
 */
public org.springframework.data.solr.core.query.Query.Operator getDefaultOperator() {
	if (hasQueryAnnotation()) {
		return getQueryAnnotation().defaultOperator();
	}
	return org.springframework.data.solr.core.query.Query.Operator.NONE;
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:11,代码来源:SolrQueryMethod.java

示例2: testQueryCreationSingleProperty

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testQueryCreationSingleProperty() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByText", String.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { "j73x73r" }));

	Assert.assertEquals("textGeneral:j73x73r", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例3: testQueryCreationWithNegativeProperty

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testQueryCreationWithNegativeProperty() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByPopularityAndPrice", Integer.class, Float.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { Integer.valueOf(-1), Float.valueOf(-2f) }));

	Assert.assertEquals("popularity:\\-1 AND price:\\-2.0", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例4: testQueryCreationMultiyProperty

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testQueryCreationMultiyProperty() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByPopularityAndPrice", Integer.class, Float.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { Integer.valueOf(1), Float.valueOf(2f) }));

	Assert.assertEquals("popularity:1 AND price:2.0", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例5: testQueryCreationWithNullProperty

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testQueryCreationWithNullProperty() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByText", String.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { null }));

	Assert.assertEquals("textGeneral:null", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例6: testWithGeoLocationProperty

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithGeoLocationProperty() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByLocationNear", Point.class, Distance.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { new Point(48.303056, 14.290556), new Distance(5) }));

	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=5.0}", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例7: testWithGeoLocationPropertyWhereDistanceIsInMiles

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithGeoLocationPropertyWhereDistanceIsInMiles() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByLocationNear", Point.class, Distance.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { new Point(48.303056, 14.290556), new Distance(1, Metrics.MILES) }));

	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java

示例8: testWithProjectionOnSingleField

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithProjectionOnSingleField() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByNameProjectionOnPopularity", String.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { "christoph" }));

	Assert.assertEquals("name:christoph*", queryParser.getQueryString(query));
	Assert.assertEquals(1, query.getProjectionOnFields().size());
	Assert.assertEquals("popularity", query.getProjectionOnFields().get(0).getName());
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:15,代码来源:StringBasedSolrQueryTests.java

示例9: testWithProjectionOnMultipleFields

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithProjectionOnMultipleFields() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByNameProjectionOnPopularityAndPrice", String.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { "strobl" }));

	Assert.assertEquals("name:strobl*", queryParser.getQueryString(query));
	Assert.assertEquals(2, query.getProjectionOnFields().size());
	Assert.assertEquals("popularity", query.getProjectionOnFields().get(0).getName());
	Assert.assertEquals("price", query.getProjectionOnFields().get(1).getName());
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:16,代码来源:StringBasedSolrQueryTests.java

示例10: testWithSort

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithSort() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByNameWithSort", String.class, Sort.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);
	Sort sort = new Sort(Direction.DESC, "popularity", "price");

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { "spring", sort }));

	Assert.assertEquals("name:spring", queryParser.getQueryString(query));
	Assert.assertEquals(sort, query.getSort());
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:15,代码来源:StringBasedSolrQueryTests.java

示例11: testWithSortInPageable

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Test
public void testWithSortInPageable() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByNameWithSortInPageable", String.class, Pageable.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);
	Sort sort = new Sort(Direction.DESC, "popularity", "price");

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { "spring", new PageRequest(0, 10, sort) }));

	Assert.assertEquals("name:spring", queryParser.getQueryString(query));
	Assert.assertEquals(sort, query.getSort());
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:15,代码来源:StringBasedSolrQueryTests.java

示例12: findAllPostDocuments

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Query("doctype:post")
List<PostDoc> findAllPostDocuments();
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:3,代码来源:CustomPostDocRepository.java

示例13: findPostDocByPostId

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Query("doctype:post AND id:?0")
PostDoc findPostDocByPostId(long postId);
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:3,代码来源:CustomPostDocRepository.java

示例14: findMoreLikeThis

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Query(value = "id:?0", requestHandler = "/mlt", filters = { "posttype:POST" })
List<PostDoc> findMoreLikeThis(long postId) throws UncategorizedSolrException;
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:3,代码来源:CustomPostDocRepository.java

示例15: findByNameStartingWith

import org.springframework.data.solr.repository.Query; //导入依赖的package包/类
@Query("name:*?0* AND doctype:product")
List<Product> findByNameStartingWith(String name);
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:3,代码来源:CustomProductRepository.java


注:本文中的org.springframework.data.solr.repository.Query类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。