use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class SolrPostTests method updatePostDocumentWithService.
@Test
public void updatePostDocumentWithService() throws Exception {
// using postId 10 which is "Solr Rama"
String postTitle = "updatePostDocumentWithService";
postDocService.updatePostDocument(updatedPost(postTitle));
PostDoc found = customPostDocRepository.findOne("10");
assertEquals(found.getPostTitle(), postTitle);
}
use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class SolrPostTests method fullSearch.
// region fullSearch tests
// fullSearch tests use the following PostDocument objects
// 100 Ways To Title Something
// This post title begins with 100 : POST
// ------------------------
// 200 Ways To Title Something
// This post title begins with 200 : POST
// ------------------------
// 1000 Ways To Title Something
// This post title begins with 1000 : POST
@Test
public void fullSearch() throws Exception {
PostQueryDTO postQueryDTO = new PostQueryDTO("body:begins", PostType.UNDEFINED);
List<PostDoc> postDocs = postDocService.doFullSearch(postQueryDTO);
assertEquals(postDocs.size(), 3);
}
use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class SolrUI method runDemos.
private void runDemos(DEMO demo) {
Query query = new SimpleQuery(new SimpleStringCriteria("doctype:post"));
List<Post> posts = postService.getAllPublishedPosts();
switch(demo) {
case MORE_LIKE_THIS:
PostDoc postDoc = postDocService.getPostDocByPostId(435L);
printPost(postDoc);
postDocList = postDocService.getMoreLikeThis(435L).subList(0, 2);
printPosts(postDocList);
break;
case POPULATE_DATABASE_SINGLE_ENTRIES:
solrOperations.delete(query);
solrOperations.commit();
System.out.println("Existing posts deleted...");
for (Post post : posts) {
System.out.println(String.format("Entering Post #%s : %s", post.getPostId(), post.getPostTitle()));
postDocService.addToIndex(post);
}
System.out.println("All posts added to Solr Server at " + solrSettings.getSolrServerUrl());
break;
case POPULATE_DATABASE_AS_LIST:
solrOperations.delete(query);
solrOperations.commit();
System.out.println("Existing posts deleted...");
postDocService.addAllToIndex(posts);
System.out.println("All posts added to Solr Server at " + solrSettings.getSolrServerUrl());
break;
case BY_LOCATION:
try {
productList = service.getProductsByLocation("35.10,-96.102");
} catch (GeoLocationException e) {
e.printStackTrace();
}
printProducts(productList);
break;
case HIGHLIGHT_SEARCH_CRITERIA:
highlightProductPage = service.findByHighlightedNameCriteria("canon powershot");
SolrUtils.processHighlights(highlightProductPage);
printProducts(highlightProductPage);
break;
case HIGHLIGHT_SEARCH:
String queryString = "Can on yep";
Boolean matches = queryString.matches("[a-zA-Z_0-9 ]*");
System.out.println("MATCHES: " + matches);
// printProducts(highlightProductPage);
break;
case SIMPLE_QUERY:
// productList = service.getProductsWithUserQuery("name:memory AND name:corsair) AND
// popularity:[6 TO *]");
// productList = service.getProductsWithUserQuery("name:Western+Digital AND inStock:TRUE");
// productList = service.getProductsWithUserQuery("cat:memory");
// productList = service.getProductsWithUserQuery("features::printer");
productList = service.getProductsWithUserQuery("inStock:true");
printProducts(productList);
break;
case FACET_ON_NAME:
facetProductPage = service.autocompleteNameFragment("pr", new PageRequest(0, 1));
Page<FacetFieldEntry> fnPage = facetProductPage.getFacetResultPage(Product.NAME_FIELD);
for (FacetFieldEntry entry : fnPage) {
System.out.println(String.format("%s:%s \t %s", entry.getField().getName(), entry.getValue(), entry.getValueCount()));
}
break;
case FACET_ON_AVAILABLE:
facetProductPage = service.getFacetedProductsAvailable();
Page<FacetFieldEntry> avPage = facetProductPage.getFacetResultPage(Product.AVAILABLE_FIELD);
for (FacetFieldEntry entry : avPage) {
System.out.println(String.format("%s:%s \t %s", entry.getField().getName(), entry.getValue(), entry.getValueCount()));
}
break;
case FACET_ON_CATEGORY:
facetProductPage = service.getFacetedProductsCategory();
Page<FacetFieldEntry> catPage = facetProductPage.getFacetResultPage(Product.CATEGORY_FIELD);
for (FacetFieldEntry entry : catPage) {
System.out.println(String.format("%s:%s \t %s", entry.getField().getName(), entry.getValue(), entry.getValueCount()));
}
break;
case METHOD_NAME_QUERY:
productList = service.getProductsByStartOfName("power cord");
printProducts(productList);
break;
case ANNOTATED_QUERY:
productList = service.getProductsByNameOrCategoryAnnotatedQuery("canon");
printProducts(productList);
break;
case NAMED_QUERY:
productIterable = service.getProductsByNameOrCategory("canon");
printProducts(productIterable);
break;
case TEST_RECORDS:
productListPage = service.getTestRecords();
printProducts(productListPage);
break;
case AVAILABLE_PRODUCTS:
productList = service.getAvailableProducts();
printProducts(productList);
break;
case ALL_PRODUCTS:
// productList = service.getProductsByFilter();
// printProducts(productList);
productList = service.getProducts();
printProducts(productList);
break;
case ALL_RECORDS:
Iterable<Product> allRecords = service.getAllRecords();
List<Product> productList = new ArrayList<>();
for (Product product : allRecords) {
if (product.getDoctype().equals(SolrDocType.PRODUCT))
productList.add(product);
}
printProducts(productList);
break;
case UPDATE_RECORD:
Product urProduct = service.getProduct(SOLR_RECORD_ID);
System.out.println(String.format("Original Product Name: %s", urProduct.getName()));
urProduct.setName("Solr, The Enterprisey Http Search Server");
service.updateProductName(urProduct);
Product urProductUpdated = service.getProduct(SOLR_RECORD_ID);
System.out.println(String.format("New Product Name: %s", urProductUpdated.getName()));
urProductUpdated.setName("Solr, The Enterprise Http Search Server");
service.updateProductName(urProductUpdated);
break;
case CRITERIA_SEARCH:
this.productList = service.searchWithCriteria("Canon Camera memory");
printProducts(this.productList);
break;
default:
break;
}
}
use of com.nixmash.blog.solr.model.PostDoc in project nixmash-blog by mintster.
the class CustomPostDocRepositoryImpl method quickSearch.
@Override
public List<PostDoc> quickSearch(String searchTerms) {
logger.debug("Searching Title and Body with Multiple Terms : {}", searchTerms);
Query query = new SimpleQuery(titleAndBodyCriteria(searchTerms));
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 CustomPostDocRepositoryImpl method pagedQuickSearch.
@Override
public Page<PostDoc> pagedQuickSearch(String searchTerms, PageRequest pageRequest) {
logger.debug("Paged Title and Body Quick Search with : {}", searchTerms);
Query query = new SimpleQuery(titleAndBodyCriteria(searchTerms));
query.setRows(1000);
query.setPageRequest(pageRequest);
Page<PostDoc> results = solrTemplate.queryForPage(query, PostDoc.class);
return results;
}
Aggregations