use of org.springframework.data.solr.core.query.Criteria in project nixmash-blog by mintster.
the class CustomPostDocRepositoryImpl method findPostsBySimpleQuery.
@Override
public List<PostDoc> findPostsBySimpleQuery(String userQuery) {
Query query = new SimpleQuery(userQuery);
query.addFilterQuery(new SimpleQuery(new Criteria(IPostDoc.DOCTYPE).is(SolrDocType.POST)));
query.setRows(1000);
Page<PostDoc> results = solrTemplate.queryForPage(query, PostDoc.class);
return results.getContent();
}
use of org.springframework.data.solr.core.query.Criteria in project nixmash-blog by mintster.
the class SolrLocationTests method testFindByLocationCriteria.
@Test
public void testFindByLocationCriteria() {
Point location = new Point(22.15, -90.85);
Criteria criteria = new Criteria("store").near(location, new Distance(5));
Page<Product> result = solrOperations.queryForPage(new SimpleQuery(criteria), Product.class);
Assert.assertEquals(1, result.getTotalElements());
Assert.assertEquals(locatedInYonkers.getId(), result.getContent().get(0).getId());
}
use of org.springframework.data.solr.core.query.Criteria in project nixmash-blog by mintster.
the class CustomPostDocRepositoryImpl method fullSearch.
@Override
public List<PostDoc> fullSearch(PostQueryDTO postQueryDTO) {
Query query = new SimpleQuery(postQueryDTO.getQuery());
if (!postQueryDTO.getPostType().equals(PostType.UNDEFINED)) {
query.addFilterQuery(new SimpleQuery(new Criteria(IPostDoc.POST_TYPE).is(postQueryDTO.getPostType())));
}
query.addFilterQuery(new SimpleQuery(new Criteria(IPostDoc.DOCTYPE).is(SolrDocType.POST)));
query.setRows(1000);
Page<PostDoc> results = solrTemplate.queryForPage(query, PostDoc.class);
return results.getContent();
}
use of org.springframework.data.solr.core.query.Criteria in project nixmash-blog by mintster.
the class CustomPostDocRepositoryImpl method titleAndBodyCriteria.
private Criteria titleAndBodyCriteria(String searchTerms) {
String[] words = searchTerms.split(" ");
Criteria criteria = new Criteria();
for (String word : words) {
criteria = criteria.and(new Criteria(PostDoc.POST_TITLE).contains(word).or(PostDoc.POST_TEXT).contains(word));
}
return criteria.and(new Criteria(PostDoc.DOCTYPE).is("post"));
}
use of org.springframework.data.solr.core.query.Criteria in project nixmash-blog by mintster.
the class CustomPostDocRepositoryImpl method pagedFullSearch.
@Override
public Page<PostDoc> pagedFullSearch(PostQueryDTO postQueryDTO, PageRequest pageRequest) {
Query query = new SimpleQuery(postQueryDTO.getQuery());
if (!postQueryDTO.getPostType().equals(PostType.UNDEFINED)) {
query.addFilterQuery(new SimpleQuery(new Criteria(IPostDoc.POST_TYPE).is(postQueryDTO.getPostType())));
}
query.addFilterQuery(new SimpleQuery(new Criteria(IPostDoc.DOCTYPE).is(SolrDocType.POST)));
query.setRows(1000);
query.setPageRequest(pageRequest);
Page<PostDoc> results = solrTemplate.queryForPage(query, PostDoc.class);
return results;
}
Aggregations