当前位置: 首页>>代码示例>>Java>>正文


Java QueryBuilders.matchAllQuery方法代码示例

本文整理汇总了Java中org.elasticsearch.index.query.QueryBuilders.matchAllQuery方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilders.matchAllQuery方法的具体用法?Java QueryBuilders.matchAllQuery怎么用?Java QueryBuilders.matchAllQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.index.query.QueryBuilders的用法示例。


在下文中一共展示了QueryBuilders.matchAllQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: randomTerminalQuery

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
private static QueryBuilder randomTerminalQuery(List<String> stringFields, List<String> numericFields, int numDocs) {
    switch (randomIntBetween(0,6)) {
        case 0:
            return randomTermQuery(stringFields, numDocs);
        case 1:
            return randomTermsQuery(stringFields, numDocs);
        case 2:
            return randomRangeQuery(numericFields, numDocs);
        case 3:
            return QueryBuilders.matchAllQuery();
        case 4:
            return randomCommonTermsQuery(stringFields, numDocs);
        case 5:
            return randomFuzzyQuery(stringFields);
        case 6:
            return randomIDsQuery();
        default:
            return randomTermQuery(stringFields, numDocs);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RandomQueryGenerator.java

示例2: testForClient

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
@Test
public void testForClient() throws Exception {
    QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
    SearchResponse searchResponse = client.prepareSearch()
            .setIndices("indexName")
            .setTypes("typeName")
            .setQuery(queryBuilder)
            .execute().actionGet();
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:10,代码来源:MatchAllQueryDemo.java

示例3: testForElasticsearchTemplate

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
@Test
public void testForElasticsearchTemplate() throws Exception {
    QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
    SearchQuery searchQuery  = new NativeSearchQuery(
            QueryBuilders.matchAllQuery()
    );
    elasticsearchTemplate.queryForList(searchQuery, GeoBoundingBox.class);
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:9,代码来源:MatchAllQueryDemo.java

示例4: CopyIndex

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
public void CopyIndex(Client sourceclient, String sourceindex, Client targetclient, String targetindex) {
	// TODO Auto-generated method stub
	count = 0;
	QueryBuilder qb = QueryBuilders.matchAllQuery();

	try {

		SearchResponse scrollResp = sourceclient.prepareSearch(sourceindex)
				.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC).setScroll(new TimeValue(60000))
				.setQuery(qb).setSize(500).execute().actionGet();

		while (true) {
			final BulkRequestBuilder bulkRequest = targetclient.prepareBulk();
			for (SearchHit hit : scrollResp.getHits().getHits()) {
				bulkRequest.add(targetclient.prepareIndex(targetindex, hit.getType().toString(), hit.getId())
						.setSource(hit.getSourceAsString()));
				count++;
			}

			bulkRequest.execute();
			scrollResp = sourceclient.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000))
					.execute().actionGet();

			logger.info(count + " documents putted!!");

			if (scrollResp.getHits().getHits().length == 0) {
				break;
			}
		}

		logger.info("copy index " + sourceindex + " " + count + " documents" + " to " + targetindex + " complete");
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:jiashiwen,项目名称:elasticbak,代码行数:37,代码来源:ElasticsearchCopyIndex.java

示例5: t_queryByEsQueryDo2

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
@org.junit.Test
public void t_queryByEsQueryDo2()throws Exception {
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    QueryBuilder qb = QueryBuilders.matchAllQuery();
    searchSourceBuilder.query(qb);
    ShapeBuilder shapeBuilder = ShapeBuilder.newPoint(new Coordinate(116.402257, 39.914548));
    QueryBuilder qb2 = QueryBuilders.geoShapeQuery("geometry", shapeBuilder, ShapeRelation.CONTAINS);

    QueryBuilder qb3 = QueryBuilders.boolQuery().must(qb).filter(qb2);
    searchSourceBuilder.query(qb3);
   iEsQueryDao.query(searchSourceBuilder,"twitter","user","user2");
    /*logger.info(JSON.toJSONString(es));
    Assert.assertNotEquals("1", es.getStatus());*/
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:15,代码来源:T_IEsQueryDao.java

示例6: queryBuilder

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
/**
     * construct the only query used by all
     *
     * @param query
     * @return
     */
    private static QueryBuilder queryBuilder(String query) {


        //return QueryBuilders.queryStringQuery(query).defaultOperator(QueryStringQueryBuilder.Operator.AND);

        if (StringUtils.isEmpty(query)) {
            return QueryBuilders.matchAllQuery();
        }

//        return QueryBuilders.multiMatchQuery(query)
//            .operator(MatchQueryBuilder.Operator.AND)
//            .field("name^3")
//            .field("content").field("path").field("version").field("project")
//            ;

        return QueryBuilders.queryStringQuery(query)
            .allowLeadingWildcard(true)
            .defaultOperator(QueryStringQueryBuilder.Operator.AND)
            .field("name^3")
            .field("content").field("path").field("version").field("project").field("extension")

            ;

        //QueryBuilders.queryStringQuery(query)
        //.defaultOperator(QueryStringQueryBuilder.Operator.AND)
        //TODO : attention, si on souhaite que la recherche s'effectue bien sur l'ensemble des champs
        //il faut veuillez à ce qu'il soit tous présent ici
        //en cas d'ajout, penser à les ajouter ici
        //.field("content")



      /*  return QueryBuilders.boolQuery()
            .should(QueryBuilders.termQuery("content", query))
            .should(
                QueryBuilders.queryStringQuery(query)
                    .defaultOperator(QueryStringQueryBuilder.Operator.AND)
            );*/
    }
 
开发者ID:klask-io,项目名称:klask-io,代码行数:46,代码来源:Queries.java

示例7: toQueryBuilder

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
private static QueryBuilder toQueryBuilder(FilterOption filterOption)
    throws ODataApplicationException {

  if (filterOption == null) {
    return QueryBuilders.matchAllQuery();
  }

  try {
    return (QueryBuilder) filterOption.getExpression()
        .accept(new ElasticsearchExpressionVisitor());
  } catch (ExpressionVisitException e) {
    throw new ODataApplicationException(
        "accept failed", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), null, e);
  }
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:16,代码来源:EntityRepository.java

示例8: main

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
public static void main(String[] args) {
   /* QueryBuilder qb1 = QueryBuilders.matchQuery("a","b");
    System.out.println(qb1.toString());*/
    String json="{\"query\":{\"match_all\":{}},\"filter\":{\"geo_shape\":{\"geometry\":{\"relation\":\"CONTAINS\",\"shape\":{\"coordinates\":[116.402257,39.914548],\"type\":\"point\"}}}}}";
    QueryBuilder qb= QueryBuilders.matchAllQuery();
    //System.out.println(qb.toString());
    SearchSourceBuilder searchSourceBuilder=new SearchSourceBuilder();
    searchSourceBuilder.query(qb);
   // System.out.println(searchSourceBuilder.toString());
    ShapeBuilder shapeBuilder= ShapeBuilder.newPoint(new Coordinate(116.402257,39.914548));
    QueryBuilder qb2= QueryBuilders.geoShapeQuery("geometry",shapeBuilder, ShapeRelation.CONTAINS);
    System.out.println(qb2.toString());

    //searchSourceBuilder.postFilter(qb2);
    QueryBuilder qb3= QueryBuilders.boolQuery().must(qb).filter(qb2);
    searchSourceBuilder.query(qb3);
    System.out.println(qb3.toString());
    System.out.println(searchSourceBuilder.toString());
    QueryBuilder qb4= QueryBuilders.boolQuery().must(qb).must(qb2);
    System.out.println(qb4.toString());


    SortBuilder sort= SortBuilders.geoDistanceSort("pin.location") .point(40, -70).
            unit(DistanceUnit.fromString(DistanceUnit.KILOMETERS.toString())).order(SortOrder.DESC);
  /*  QueryBuilder qb5 = QueryBuilders.geoDistanceQuery("pin.location")
            .point(40, -70)
            .distance(400,  DistanceUnit.fromString(DistanceUnit.KILOMETERS.toString()))
            .geoDistance(GeoDistance.ARC);
             System.out.println(qb5.toString());
            */
    searchSourceBuilder.sort(sort);
    System.out.println(searchSourceBuilder.toString());
    //QueryBuilder qb3=QueryBuilders.filteredQuery(null,qb2);
    //QueryBuilder qb4=QueryBuilders.filteredQuery(qb,qb2);
    //searchSourceBuilder.query(qb3.toString());
   // searchSourceBuilder.query(qb4);
   // System.out.println(qb4.toString());
    //System.out.println(searchSourceBuilder.toString());

    // System.out.println(qb.toString());
   /* QueryBuilder qb2 = QueryBuilders.geoBoundingBoxQuery("pin.location")
            .topLeft(40.73, -74.1)
            .bottomRight(40.717, -73.99);
    //String  strstr= JSON.toJSONString(qb2);
    System.out.println(qb2.toString());
    System.out.println("1111111");*/
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:48,代码来源:Test.java

示例9: getDocCount

import org.elasticsearch.index.query.QueryBuilders; //导入方法依赖的package包/类
public int getDocCount(String index, String... type) {
  MatchAllQueryBuilder search = QueryBuilders.matchAllQuery();
  String[] indexArr = new String[] { index };
  return this.getDocCount(indexArr, type, search);
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:6,代码来源:ESDriver.java


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