Search in sources :

Example 1 with SimpleStringCriteria

use of org.springframework.data.solr.core.query.SimpleStringCriteria 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 2 with SimpleStringCriteria

use of org.springframework.data.solr.core.query.SimpleStringCriteria 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);
}
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) SimpleStringCriteria(org.springframework.data.solr.core.query.SimpleStringCriteria) PostDoc(com.nixmash.blog.solr.model.PostDoc) Test(org.junit.Test)

Example 3 with SimpleStringCriteria

use of org.springframework.data.solr.core.query.SimpleStringCriteria 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);
}
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) Before(org.junit.Before)

Example 4 with SimpleStringCriteria

use of org.springframework.data.solr.core.query.SimpleStringCriteria in project nixmash-blog by mintster.

the class PostDocServiceImpl method reindexPosts.

@Transactional
@Override
public void reindexPosts(List<Post> posts) {
    Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
    solrOperations.delete(query);
    solrOperations.commit();
    addAllToIndex(posts);
}
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) SimpleStringCriteria(org.springframework.data.solr.core.query.SimpleStringCriteria) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with SimpleStringCriteria

use of org.springframework.data.solr.core.query.SimpleStringCriteria in project nixmash-blog by mintster.

the class AdminSolrPostsControllerTests method setup.

// endregion
// region Before / After
@Before
public void setup() throws ServletException {
    // ObjectMapper objectMapper = new ObjectMapper();
    // JacksonTester.initFields(this, objectMapper);
    mvc = webAppContextSetup(wac).apply(springSecurity()).build();
    Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
    solrOperations.delete(query);
    solrOperations.commit();
    List<Post> posts = postService.getAllPublishedPosts();
    postDocService.addAllToIndex(posts);
}
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) Before(org.junit.Before)

Aggregations

Query (org.springframework.data.solr.core.query.Query)9 SimpleQuery (org.springframework.data.solr.core.query.SimpleQuery)9 SimpleStringCriteria (org.springframework.data.solr.core.query.SimpleStringCriteria)9 Post (com.nixmash.blog.jpa.model.Post)4 PostDoc (com.nixmash.blog.solr.model.PostDoc)3 Before (org.junit.Before)3 After (org.junit.After)2 Test (org.junit.Test)2 GeoLocationException (com.nixmash.blog.solr.exceptions.GeoLocationException)1 Product (com.nixmash.blog.solr.model.Product)1 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 PageRequest (org.springframework.data.domain.PageRequest)1 FacetFieldEntry (org.springframework.data.solr.core.query.result.FacetFieldEntry)1 Transactional (org.springframework.transaction.annotation.Transactional)1