本文整理匯總了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);
}