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


Java SearchPhaseExecutionException类代码示例

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


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

示例1: minMaxQuery

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
private SearchResponse minMaxQuery(ScoreMode scoreMode, int minChildren, Integer maxChildren) throws SearchPhaseExecutionException {
    HasChildQueryBuilder hasChildQuery = hasChildQuery(
            "child",
            QueryBuilders.functionScoreQuery(constantScoreQuery(QueryBuilders.termQuery("foo", "two")),
                    new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
                            new FunctionScoreQueryBuilder.FilterFunctionBuilder(weightFactorFunction(1)),
                            new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.termQuery("foo", "three"), weightFactorFunction(1)),
                            new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.termQuery("foo", "four"), weightFactorFunction(1))
                    }).boostMode(CombineFunction.REPLACE).scoreMode(FiltersFunctionScoreQuery.ScoreMode.SUM), scoreMode)
            .minMaxChildren(minChildren, maxChildren != null ? maxChildren : HasChildQueryBuilder.DEFAULT_MAX_CHILDREN);

    return client()
            .prepareSearch("test")
            .setQuery(hasChildQuery)
            .addSort("_score", SortOrder.DESC).addSort("id", SortOrder.ASC).get();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:ChildQuerySearchIT.java

示例2: testPercolatorQueryExistingDocumentSourceDisabled

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception {
    createIndex("test", client().admin().indices().prepareCreate("test")
        .addMapping("type", "_source", "enabled=false", "field1", "type=keyword")
        .addMapping("queries", "query", "type=percolator")
    );

    client().prepareIndex("test", "queries", "1")
        .setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
        .get();

    client().prepareIndex("test", "type", "1").setSource("{}", XContentType.JSON).get();
    client().admin().indices().prepareRefresh().get();

    logger.info("percolating empty doc with source disabled");
    Throwable e = expectThrows(SearchPhaseExecutionException.class, () -> {
        client().prepareSearch()
            .setQuery(new PercolateQueryBuilder("query", "type", "test", "type", "1", null, null, null))
            .get();
    }).getRootCause();
    assertThat(e, instanceOf(IllegalArgumentException.class));
    assertThat(e.getMessage(), containsString("source disabled"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:PercolatorQuerySearchIT.java

示例3: checkExceptions

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
private void checkExceptions(Script script) {
    try {
        SearchResponse sr = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()).addScriptField("tvtest", script)
                .execute().actionGet();
        assertThat(sr.getHits().getHits().length, equalTo(0));
        ShardSearchFailure[] shardFails = sr.getShardFailures();
        for (ShardSearchFailure fail : shardFails) {
            assertThat(fail.reason().indexOf("Cannot iterate twice! If you want to iterate more that once, add _CACHE explicitly."),
                    Matchers.greaterThan(-1));
        }
    } catch (SearchPhaseExecutionException ex) {
        assertThat(
                "got " + ex.toString(),
                ex.toString().indexOf("Cannot iterate twice! If you want to iterate more that once, add _CACHE explicitly."),
                Matchers.greaterThan(-1));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:IndexLookupIT.java

示例4: testBadPercents

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testBadPercents() throws Exception {
    double[] badPercents = {-1.0, 110.0};

    try {
        client().prepareSearch("idx")
                .addAggregation(terms("terms").field("tag").subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
                .addAggregation(percentilesBucket("percentiles_bucket", "terms>sum")
                        .percents(badPercents)).execute().actionGet();

        fail("Illegal percent's were provided but no exception was thrown.");
    } catch (Exception e) {
        Throwable cause = ExceptionsHelper.unwrapCause(e);
        if (cause == null) {
            throw e;
        } else if (cause instanceof SearchPhaseExecutionException) {
            SearchPhaseExecutionException spee = (SearchPhaseExecutionException) e;
            Throwable rootCause = spee.getRootCause();
            if (!(rootCause instanceof IllegalArgumentException)) {
                throw e;
            }
        } else if (!(cause instanceof IllegalArgumentException)) {
            throw e;
        }
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:PercentilesBucketIT.java

示例5: testBadParent

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testBadParent() {
    try {
        client()
                .prepareSearch("idx").setTypes("type")
                .addAggregation(
                        range("histo").field(INTERVAL_FIELD).addRange(0, 10)
                                .subAggregation(randomMetric("the_metric", VALUE_FIELD))
                                .subAggregation(movingAvg("movavg_counts", "the_metric")
                                        .window(windowSize)
                                        .modelBuilder(new SimpleModel.SimpleModelBuilder())
                                        .gapPolicy(gapPolicy))
                ).execute().actionGet();
        fail("MovingAvg should not accept non-histogram as parent");

    } catch (SearchPhaseExecutionException exception) {
        // All good
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:MovAvgIT.java

示例6: testHoltWintersNotEnoughData

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testHoltWintersNotEnoughData() {
    try {
        SearchResponse response = client()
                .prepareSearch("idx").setTypes("type")
                .addAggregation(
                        histogram("histo").field(INTERVAL_FIELD).interval(interval)
                                .extendedBounds(0L, (long) (interval * (numBuckets - 1)))
                                .subAggregation(metric)
                                .subAggregation(movingAvg("movavg_counts", "_count")
                                        .window(10)
                                        .modelBuilder(new HoltWintersModel.HoltWintersModelBuilder()
                                                .alpha(alpha).beta(beta).gamma(gamma).period(20).seasonalityType(seasonalityType))
                                        .gapPolicy(gapPolicy))
                                .subAggregation(movingAvg("movavg_values", "the_metric")
                                        .window(windowSize)
                                        .modelBuilder(new HoltWintersModel.HoltWintersModelBuilder()
                                                .alpha(alpha).beta(beta).gamma(gamma).period(20).seasonalityType(seasonalityType))
                                        .gapPolicy(gapPolicy))
                ).execute().actionGet();
    } catch (SearchPhaseExecutionException e) {
        // All good
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:MovAvgIT.java

示例7: testBadModelParams

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testBadModelParams() {
    try {
        SearchResponse response = client()
                .prepareSearch("idx").setTypes("type")
                .addAggregation(
                        histogram("histo").field(INTERVAL_FIELD).interval(interval)
                                .extendedBounds(0L, (long) (interval * (numBuckets - 1)))
                                .subAggregation(metric)
                                .subAggregation(movingAvg("movavg_counts", "_count")
                                        .window(10)
                                        .modelBuilder(randomModelBuilder(100))
                                        .gapPolicy(gapPolicy))
                ).execute().actionGet();
    } catch (SearchPhaseExecutionException e) {
        // All good
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:MovAvgIT.java

示例8: testTooLargeMatrix

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testTooLargeMatrix() throws Exception{

        // Create more filters than is permitted by index settings.
        MapBuilder filtersMap = new MapBuilder();
        for (int i = 0; i <= MAX_NUM_FILTERS; i++) {
            filtersMap.add("tag" + i, termQuery("tag", "tag" + i));
        }

        try {
            client().prepareSearch("idx")
                .addAggregation(adjacencyMatrix("tags", "\t", filtersMap))
                .execute().actionGet();
            fail("SearchPhaseExecutionException should have been thrown");
        } catch (SearchPhaseExecutionException ex) {
            assertThat(ex.getCause().getMessage(), containsString("Number of filters is too large"));
        }
    }
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:AdjacencyMatrixIT.java

示例9: testReverseNestedAggWithoutNestedAgg

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testReverseNestedAggWithoutNestedAgg() {
    try {
        client().prepareSearch("idx")
                .addAggregation(terms("field2").field("nested1.nested2.field2")
                        .collectMode(randomFrom(SubAggCollectionMode.values()))
                                .subAggregation(
                                        reverseNested("nested1_to_field1")
                                                .subAggregation(
                                                        terms("field1").field("nested1.field1")
                                                        .collectMode(randomFrom(SubAggCollectionMode.values()))
                                                )
                                )
                ).get();
        fail("Expected SearchPhaseExecutionException");
    } catch (SearchPhaseExecutionException e) {
        assertThat(e.getMessage(), is("all shards failed"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ReverseNestedIT.java

示例10: testCloseSearchContextOnRewriteException

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testCloseSearchContextOnRewriteException() {
    createIndex("index");
    client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();

    SearchService service = getInstanceFromNode(SearchService.class);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
    IndexShard indexShard = indexService.getShard(0);

    final int activeContexts = service.getActiveContexts();
    final int activeRefs = indexShard.store().refCount();
    expectThrows(SearchPhaseExecutionException.class, () ->
            client().prepareSearch("index").setQuery(new FailOnRewriteQueryBuilder()).get());
    assertEquals(activeContexts, service.getActiveContexts());
    assertEquals(activeRefs, indexShard.store().refCount());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SearchServiceTests.java

示例11: testExceptionThrownIfScaleLE0

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testExceptionThrownIfScaleLE0() throws Exception {
    assertAcked(prepareCreate("test").addMapping(
            "type1",
            jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text")
                    .endObject().startObject("num1").field("type", "date").endObject().endObject().endObject().endObject()));
    client().index(
            indexRequest("test").type("type1").id("1")
                    .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())).actionGet();
    client().index(
            indexRequest("test").type("type1").id("2")
                    .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-28").endObject())).actionGet();
    refresh();

    ActionFuture<SearchResponse> response = client().search(
            searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
                    searchSource().query(
                            functionScoreQuery(termQuery("test", "value"), gaussDecayFunction("num1", "2013-05-28", "-1d")))));
    try {
        response.actionGet();
        fail("Expected SearchPhaseExecutionException");
    } catch (SearchPhaseExecutionException e) {
        assertThat(e.getMessage(), is("all shards failed"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DecayFunctionScoreIT.java

示例12: testParsingExceptionIfFieldTypeDoesNotMatch

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception {
    assertAcked(prepareCreate("test").addMapping(
            "type",
            jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text")
                    .endObject().startObject("num").field("type", "text").endObject().endObject().endObject().endObject()));
    client().index(
            indexRequest("test").type("type").source(
                    jsonBuilder().startObject().field("test", "value").field("num", Integer.toString(1)).endObject())).actionGet();
    refresh();
    // so, we indexed a string field, but now we try to score a num field
    ActionFuture<SearchResponse> response = client().search(searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
            .source(searchSource().query(functionScoreQuery(termQuery("test", "value"), linearDecayFunction("num", 1.0, 0.5))
                    .scoreMode(ScoreMode.MULTIPLY))));
    try {
        response.actionGet();
        fail("Expected SearchPhaseExecutionException");
    } catch (SearchPhaseExecutionException e) {
        assertThat(e.getMessage(), is("all shards failed"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:DecayFunctionScoreIT.java

示例13: testDateRangeInQueryString

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testDateRangeInQueryString() {
    //the mapping needs to be provided upfront otherwise we are not sure how many failures we get back
    //as with dynamic mappings some shards might be lacking behind and parse a different query
    assertAcked(prepareCreate("test").addMapping(
            "type", "past", "type=date", "future", "type=date"
    ));

    String aMonthAgo = ISODateTimeFormat.yearMonthDay().print(new DateTime(DateTimeZone.UTC).minusMonths(1));
    String aMonthFromNow = ISODateTimeFormat.yearMonthDay().print(new DateTime(DateTimeZone.UTC).plusMonths(1));
    client().prepareIndex("test", "type", "1").setSource("past", aMonthAgo, "future", aMonthFromNow).get();
    refresh();

    SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("past:[now-2M/d TO now/d]")).get();
    assertHitCount(searchResponse, 1L);

    searchResponse = client().prepareSearch().setQuery(queryStringQuery("future:[now/d TO now+2M/d]")).get();
    assertHitCount(searchResponse, 1L);

    SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch()
            .setQuery(queryStringQuery("future:[now/D TO now+2M/d]").lenient(false)).get());
    assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
    assertThat(e.toString(), containsString("unit [D] not supported for date math"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:SearchQueryIT.java

示例14: testMatchQueryNumeric

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testMatchQueryNumeric() throws Exception {
    assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double"));

    indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("long", 1L, "double", 1.0d),
            client().prepareIndex("test", "type1", "2").setSource("long", 2L, "double", 2.0d),
            client().prepareIndex("test", "type1", "3").setSource("long", 3L, "double", 3.0d));

    SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("long", "1")).get();
    assertHitCount(searchResponse, 1L);
    assertFirstHit(searchResponse, hasId("1"));

    searchResponse = client().prepareSearch().setQuery(matchQuery("double", "2")).get();
    assertHitCount(searchResponse, 1L);
    assertFirstHit(searchResponse, hasId("2"));
    expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch().setQuery(matchQuery("double", "2 3 4")).get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SearchQueryIT.java

示例15: testThatSortingOnCompletionFieldReturnsUsefulException

import org.elasticsearch.action.search.SearchPhaseExecutionException; //导入依赖的package包/类
public void testThatSortingOnCompletionFieldReturnsUsefulException() throws Exception {
    createIndexAndMapping(completionMappingBuilder);

    client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
            .startObject().startObject(FIELD)
            .startArray("input").value("Nirvana").endArray()
            .endObject().endObject()
    ).get();

    refresh();
    try {
        client().prepareSearch(INDEX).setTypes(TYPE).addSort(new FieldSortBuilder(FIELD)).execute().actionGet();
        fail("Expected an exception due to trying to sort on completion field, but did not happen");
    } catch (SearchPhaseExecutionException e) {
        assertThat(e.status().getStatus(), is(400));
        assertThat(e.toString(), containsString("Fielddata is not supported on field [" + FIELD + "] of type [completion]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:CompletionSuggestSearchIT.java


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