本文整理汇总了Java中org.springframework.data.elasticsearch.core.query.IndexQueryBuilder类的典型用法代码示例。如果您正苦于以下问题:Java IndexQueryBuilder类的具体用法?Java IndexQueryBuilder怎么用?Java IndexQueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexQueryBuilder类属于org.springframework.data.elasticsearch.core.query包,在下文中一共展示了IndexQueryBuilder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initData
import org.springframework.data.elasticsearch.core.query.IndexQueryBuilder; //导入依赖的package包/类
@PostConstruct
private void initData() {
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
LoremIpsum lorem = new LoremIpsum();
for (int i = MINCOUNT; i < MAXCOUNT; i++) {
String documentId = UUID.randomUUID().toString();
Book book = new Book();
book.setId(documentId);
book.setName(lorem.randomWord());
book.setMessage(lorem.sentence());
book.setPrice(RandomUtils.nextDouble());
IndexQuery indexQuery = new IndexQueryBuilder()
.withId(book.getId()).withObject(book).build();
indexQueries.add(indexQuery);
}
// bulk index
elasticsearchTemplate.bulkIndex(indexQueries);
}
示例2: saveTest
import org.springframework.data.elasticsearch.core.query.IndexQueryBuilder; //导入依赖的package包/类
@Test
public void saveTest() {
Book book = new Book();
book.setId("56");
book.setAuthors(Lists.newArrayList("ray", "yrq"));
book.setName("el_template33");
book.setPrice((double) 10);
book.setPublishDate(new Date());
IndexQueryBuilder indexQueryBuilder = new IndexQueryBuilder();
indexQueryBuilder.withObject(book).withId(book.getId());
String documentId = elasticsearchTemplate.index(indexQueryBuilder.build());
System.out.println(documentId);
}