use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class SolrUI method printPosts.
private void printPosts(Iterable<? extends PostDoc> posts) {
int i = 0;
System.out.println("More Like This Posts -------------------------- */\n");
for (PostDoc postDoc : posts) {
MessageFormat mf = new MessageFormat("{0} | Post: {1}");
Object[] items = { postDoc.getPostId(), postDoc.getPostTitle() };
System.out.println(mf.format(items));
i++;
}
System.out.println("");
}
use of com.nixmash.blog.solr.model.PostDoc 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 com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class AdminSolrPostsControllerTests method updatingPostUpdatesItsSolrPostDocument.
@Test
public void updatingPostUpdatesItsSolrPostDocument() throws Exception {
List<PostDoc> postDocs = postDocService.getAllPostDocuments();
int postDocCount = postDocs.size();
Post post = postService.getPostById(1L);
String originalTitle = post.getPostTitle();
String newTitle = "updatingPostUpdatesItsSolrPostDocument";
mvc.perform(post("/admin/posts/update").param("postId", "1").param("displayType", String.valueOf(post.getDisplayType())).param("postContent", post.getPostContent()).param("postTitle", newTitle).param("twitterCardType", TWITTER_SUMMARY).param("tags", "removingTag1").with(csrf()));
// size of PostDocuments in Solr Index Unchanged
assertEquals(postDocCount, postDocService.getAllPostDocuments().size());
Post verifyPost = postService.getPostById(1L);
assertEquals(verifyPost.getPostTitle(), newTitle);
List<PostDoc> verifyPostDocs = postDocService.getPostsWithUserQuery(newTitle);
assertEquals(verifyPostDocs.size(), 1);
}
use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class PostDocServiceImpl method getMoreLikeThisPostsFromPostDocs.
@Transactional(readOnly = true)
@Override
public List<Post> getMoreLikeThisPostsFromPostDocs(List<PostDoc> postDocs) {
List<Post> posts = new ArrayList<>();
String result = StringUtils.EMPTY;
for (int i = 0; i < applicationSettings.getMoreLikeThisNum(); i++) {
try {
PostDoc postDoc = postDocs.get(i);
posts.add(postService.getPostById(Long.parseLong(postDoc.getPostId())));
} catch (PostNotFoundException | IndexOutOfBoundsException e) {
if (e.getClass().equals(PostNotFoundException.class))
logger.info("MoreLikeThis PostDoc {} to Post with title \"{}\" NOT FOUND", postDocs.get(i).getPostId(), postDocs.get(i).getPostTitle());
else {
logger.info("EXCEPTION: AppSetting.MoreLikeThisNum > post count");
return null;
}
}
}
return posts;
}
use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class SolrPostTests method addPostWithAddToIndexService.
@Test
public void addPostWithAddToIndexService() throws Exception {
// using postId 10 which is "Solr Rama"
Post post = postService.getPostById(10L);
postDocService.addToIndex(post);
PostDoc found = customPostDocRepository.findOne("10");
assertEquals(found.getPostName(), "solr-rama");
}
Aggregations