當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。