use of com.tangtang.elasticsearchexample.domain.Article in project benchmark by seelunzi.
the class TestContreller method testSaveArticleIndex.
@RequestMapping("/add")
public void testSaveArticleIndex() {
Author author = new Author();
author.setId(1L);
author.setName("tianshouzhi");
author.setRemark("java developer");
Tutorial tutorial = new Tutorial();
tutorial.setId(1L);
tutorial.setName("elastic search");
Article article = new Article();
article.setId(1L);
article.setTitle("springboot integreate elasticsearch");
article.setAbstracts("springboot integreate elasticsearch is very easy");
article.setTutorial(tutorial);
article.setAuthor(author);
article.setContent("elasticsearch based on lucene," + "spring-data-elastichsearch based on elaticsearch" + ",this tutorial tell you how to integrete springboot with spring-data-elasticsearch");
article.setPostTime(new Date());
article.setClickCount(1L);
articleSearchRepository.save(article);
}
use of com.tangtang.elasticsearchexample.domain.Article in project benchmark by seelunzi.
the class TestContreller method testSearch.
@RequestMapping("/query")
public void testSearch() {
// 搜索关键字
String queryString = "springboot";
QueryStringQueryBuilder builder = new QueryStringQueryBuilder(queryString);
Iterable<Article> searchResult = articleSearchRepository.search(builder);
Iterator<Article> iterator = searchResult.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
Aggregations