use of org.springframework.data.solr.core.query.SimpleQuery in project nixmash-blog by mintster.
the class SolrPostReindexTests method cleanAndReindexPostDocuments_AddIndividually.
@Test
@Ignore(value = "It works, no need to wait for it to run each time")
public void cleanAndReindexPostDocuments_AddIndividually() throws Exception {
posts = postService.getAllPublishedPosts();
postCount = posts.size();
for (Post post : posts) {
postDocService.addToIndex(post);
}
List<PostDoc> postDocs = postDocService.getAllPostDocuments();
assertEquals(postDocs.size(), postCount);
postDocs = postDocService.getPostsWithUserQuery("bootstrap");
assertEquals(BOOTSTRAP_POST_COUNT, postDocs.size());
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
solrOperations.delete(query);
solrOperations.commit();
}
use of org.springframework.data.solr.core.query.SimpleQuery in project nixmash-blog by mintster.
the class SolrPostTests method queryForPage.
@Test
public void queryForPage() {
int postCount = postService.getAllPublishedPosts().size();
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
Page<PostDoc> postDocs = solrOperations.queryForPage(query, PostDoc.class);
assertEquals(postDocs.getTotalElements(), postCount);
}
use of org.springframework.data.solr.core.query.SimpleQuery in project nixmash-blog by mintster.
the class SolrPostTests method setupSolr.
@Before
public void setupSolr() {
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
solrOperations.delete(query);
solrOperations.commit();
List<Post> posts = postService.getAllPublishedPosts();
postDocService.addAllToIndex(posts);
}
use of org.springframework.data.solr.core.query.SimpleQuery 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.SimpleQuery in project nixmash-blog by mintster.
the class PostDocServiceImpl method removeFromIndex.
@Transactional
@Override
public void removeFromIndex(String query) {
solrOperations.delete(new SimpleQuery(query));
commit();
}
Aggregations