• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IndexQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.elasticsearch.core.query.IndexQuery的典型用法代码示例。如果您正苦于以下问题:Java IndexQuery类的具体用法?Java IndexQuery怎么用?Java IndexQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndexQuery类属于org.springframework.data.elasticsearch.core.query包,在下文中一共展示了IndexQuery类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: index

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
default void index(Collection<? extends T> objects) {
    if (objects.isEmpty()) {
        return;
    }

    List<IndexQuery> queries = objects.stream()
            .map(obj -> {
                IndexQuery query = new IndexQuery();
                query.setId(obj.getId());

                query.setObject(this.toIndexObject(obj));

                return query;
            })
            .collect(Collectors.toList());

    getTemplate().bulkIndex(queries);
    getTemplate().refresh(getUType());
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:20,代码来源:IndexedStore.java


示例2: before

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
@Before
public void before() {
	elasticsearchTemplate.deleteIndex(ArticleEntity.class);
	elasticsearchTemplate.createIndex(ArticleEntity.class);
	elasticsearchTemplate.putMapping(ArticleEntity.class);
	elasticsearchTemplate.refresh(ArticleEntity.class);

	IndexQuery article1 = new ArticleEntityBuilder("1").title("article four").subject("computing").addAuthor(RIZWAN_IDREES).addAuthor(ARTUR_KONCZAK).addAuthor(MOHSIN_HUSEN).addAuthor(JONATHAN_YAN).score(10).buildIndex();
	IndexQuery article2 = new ArticleEntityBuilder("2").title("article three").subject("computing").addAuthor(RIZWAN_IDREES).addAuthor(ARTUR_KONCZAK).addAuthor(MOHSIN_HUSEN).addPublishedYear(YEAR_2000).score(20).buildIndex();
	IndexQuery article3 = new ArticleEntityBuilder("3").title("article two").subject("computing").addAuthor(RIZWAN_IDREES).addAuthor(ARTUR_KONCZAK).addPublishedYear(YEAR_2001).addPublishedYear(YEAR_2000).score(30).buildIndex();
	IndexQuery article4 = new ArticleEntityBuilder("4").title("article one").subject("accounting").addAuthor(RIZWAN_IDREES).addPublishedYear(YEAR_2002).addPublishedYear(YEAR_2001).addPublishedYear(YEAR_2000).score(40).buildIndex();

	elasticsearchTemplate.index(article1);
	elasticsearchTemplate.index(article2);
	elasticsearchTemplate.index(article3);
	elasticsearchTemplate.index(article4);
	elasticsearchTemplate.refresh(ArticleEntity.class);
}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:19,代码来源:ElasticsearchTemplateAggregationTests.java


示例3: buildIndex

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
public static IndexQuery buildIndex(Object object) {
	for (Field f : object.getClass().getDeclaredFields()) {
		if (ArrayUtils.isNotEmpty(f.getAnnotationsByType(org.springframework.data.annotation.Id.class))) {
			try {
				f.setAccessible(true);
				IndexQuery indexQuery = new IndexQuery();
				indexQuery.setId((String) f.get(object));
				indexQuery.setObject(object);
				return indexQuery;
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
	}
	throw new RuntimeException("Missing @Id field");
}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:17,代码来源:IndexBuilder.java


示例4: initData

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的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);
}
 
开发者ID:phstudy,项目名称:SpringMVC-SpringDataElasticsearch,代码行数:20,代码来源:HomeController.java


示例5: save

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
@Override
public TYPE save(TYPE entity, Class<TYPE> entityClass) throws DataLayerException {
    if (!elasticsearchTemplate.indexExists(entityClass)) {
        elasticsearchTemplate.createIndex(entityClass);
        elasticsearchTemplate.putMapping(entityClass);
    }
    IndexQuery indexQuery = new IndexQuery();
    if (entity.getId() == null) {
        entity.setId(UUID.randomUUID().toString());
    }
    indexQuery.setId(entity.getId());
    indexQuery.setObject(entity);
    elasticsearchTemplate.index(indexQuery);
    elasticsearchTemplate.refresh(entityClass, true);
    return entity;
}
 
开发者ID:alv-ch,项目名称:alv-ch-java,代码行数:17,代码来源:ElasticsearchDataStoreAdapter.java


示例6: testGeoBoundingBoxQueryForElasticsearchTemplate

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
@Test
public void testGeoBoundingBoxQueryForElasticsearchTemplate() throws Exception {

    elasticsearchTemplate.createIndex("universities");
    elasticsearchTemplate.putMapping(GeoBoundingBox.class);

    List<IndexQuery> indexQueryList = new ArrayList<>();
    GeoBoundingBox geoBoundingBox = new GeoBoundingBox("中国传媒大学",new Location(39.918054,116.56387));
    IndexQuery indexQuery  = new IndexQuery();
    indexQuery.setId(UUID.randomUUID().toString());
    indexQuery.setIndexName("universities");
    indexQuery.setType("university");
    indexQuery.setSource(JSON.toJSONString(geoBoundingBox));
    indexQuery.setObject(geoBoundingBox);
    indexQueryList.add(indexQuery);

    GeoBoundingBox geoBoundingBox1 = new GeoBoundingBox("北京邮电大学",new Location(39.967366,116.364695));
    IndexQuery indexQuery1  = new IndexQuery();
    indexQuery1.setId(UUID.randomUUID().toString());
    indexQuery1.setIndexName("universities");
    indexQuery1.setType("university");
    indexQuery1.setSource(JSON.toJSONString(geoBoundingBox1));
    indexQuery1.setObject(geoBoundingBox1);
    indexQueryList.add(indexQuery1);

    GeoBoundingBox geoBoundingBox2 = new GeoBoundingBox("北京航空航天大学",new Location(39.986069,116.35347));
    IndexQuery indexQuery2  = new IndexQuery();
    indexQuery2.setId(UUID.randomUUID().toString());
    indexQuery2.setIndexName("universities");
    indexQuery2.setType("university");
    indexQuery2.setSource(JSON.toJSONString(geoBoundingBox2));
    indexQuery2.setObject(geoBoundingBox2);
    indexQueryList.add(indexQuery2);

    elasticsearchTemplate.bulkIndex(indexQueryList);

    QueryBuilder queryBuilder =
            QueryBuilders.geoBoundingBoxQuery("location")
                    .setCorners(40.124125,113.493763,39.816239,117.237612);

    SearchQuery searchQuery = new NativeSearchQuery(queryBuilder);

    List<GeoBoundingBox> geoBoundingBoxes = elasticsearchTemplate.queryForList(searchQuery,GeoBoundingBox.class);
    System.out.println(JSON.toJSONString(geoBoundingBox));



}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:49,代码来源:GeoPointDemo.java


示例7: buildIndex

import org.springframework.data.elasticsearch.core.query.IndexQuery; //导入依赖的package包/类
public IndexQuery buildIndex() {
	IndexQuery indexQuery = new IndexQuery();
	indexQuery.setId(result.getId());
	indexQuery.setObject(result);
	return indexQuery;
}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:7,代码来源:ArticleEntityBuilder.java



注:本文中的org.springframework.data.elasticsearch.core.query.IndexQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Statement类代码示例发布时间:2022-05-22
下一篇:
Java MessageFormatRuntimeException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap