Search in sources :

Example 6 with PostDoc

use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.

the class PostDocServiceImpl method addToIndex.

@Transactional
@Override
public void addToIndex(Post post) {
    logger.debug("Saving a Post Document with information: {}", post);
    PostDoc document = SolrUtils.createPostDoc(post);
    customPostDocRepository.save(document);
    commit();
}
Also used : PostDoc(com.nixmash.blog.solr.model.PostDoc) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with PostDoc

use of com.nixmash.blog.solr.model.PostDoc 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();
}
Also used : SimpleQuery(org.springframework.data.solr.core.query.SimpleQuery) Query(org.springframework.data.solr.core.query.Query) SimpleQuery(org.springframework.data.solr.core.query.SimpleQuery) Post(com.nixmash.blog.jpa.model.Post) SimpleStringCriteria(org.springframework.data.solr.core.query.SimpleStringCriteria) PostDoc(com.nixmash.blog.solr.model.PostDoc) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with PostDoc

use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.

the class SolrPostTests method addPostWithRepository.

@Test
public void addPostWithRepository() throws Exception {
    // using postId 10 which is "Solr Rama"
    Post post = postService.getPostById(10L);
    PostDoc postDoc = SolrUtils.createPostDoc(post);
    customPostDocRepository.save(postDoc);
    PostDoc found = customPostDocRepository.findOne("10");
    assertEquals(found.getPostName(), "solr-rama");
    customPostDocRepository.delete("10");
}
Also used : Post(com.nixmash.blog.jpa.model.Post) PostDoc(com.nixmash.blog.solr.model.PostDoc) Test(org.junit.Test)

Example 9 with PostDoc

use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.

the class SolrPostTests method fullSearchWithPostType_POST_ReturnsAll.

@Test
public void fullSearchWithPostType_POST_ReturnsAll() throws Exception {
    PostQueryDTO postQueryDTO = new PostQueryDTO("body:begins", PostType.POST);
    List<PostDoc> postDocs = postDocService.doFullSearch(postQueryDTO);
    assertEquals(postDocs.size(), 3);
}
Also used : PostQueryDTO(com.nixmash.blog.jpa.dto.PostQueryDTO) PostDoc(com.nixmash.blog.solr.model.PostDoc) Test(org.junit.Test)

Example 10 with PostDoc

use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.

the class SolrPostTests method findPostDocByPostIdNotNullWithService.

@Test
public void findPostDocByPostIdNotNullWithService() throws Exception {
    PostDoc postDoc = postDocService.getPostDocByPostId(1L);
    assertNotNull(postDoc);
}
Also used : PostDoc(com.nixmash.blog.solr.model.PostDoc) Test(org.junit.Test)

Aggregations

PostDoc (com.nixmash.blog.solr.model.PostDoc)26 Test (org.junit.Test)13 Post (com.nixmash.blog.jpa.model.Post)8 Query (org.springframework.data.solr.core.query.Query)8 SimpleQuery (org.springframework.data.solr.core.query.SimpleQuery)8 IPostDoc (com.nixmash.blog.solr.model.IPostDoc)5 PostQueryDTO (com.nixmash.blog.jpa.dto.PostQueryDTO)4 ArrayList (java.util.ArrayList)3 Criteria (org.springframework.data.solr.core.query.Criteria)3 SimpleStringCriteria (org.springframework.data.solr.core.query.SimpleStringCriteria)3 Transactional (org.springframework.transaction.annotation.Transactional)3 PostNotFoundException (com.nixmash.blog.jpa.exceptions.PostNotFoundException)1 JsonRequestMapping (com.nixmash.blog.mvc.annotations.JsonRequestMapping)1 GeoLocationException (com.nixmash.blog.solr.exceptions.GeoLocationException)1 Product (com.nixmash.blog.solr.model.Product)1 MessageFormat (java.text.MessageFormat)1 Ignore (org.junit.Ignore)1 PageRequest (org.springframework.data.domain.PageRequest)1 UncategorizedSolrException (org.springframework.data.solr.UncategorizedSolrException)1 FacetFieldEntry (org.springframework.data.solr.core.query.result.FacetFieldEntry)1