Java 类org.apache.lucene.util.automaton.TooComplexToDeterminizeException 实例源码

项目:elasticsearch_my    文件:QueryStringQueryBuilderTests.java   
/**
 * Validates that {@code max_determinized_states} can be parsed and lowers the allowed number of determinized states.
 */
public void testToQueryRegExpQueryMaxDeterminizedStatesParsing() throws Exception {
    assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
    XContentBuilder builder = JsonXContent.contentBuilder();
    builder.startObject(); {
        builder.startObject("query_string"); {
            builder.field("query", "/[ac]*a[ac]{1,10}/");
            builder.field("default_field", STRING_FIELD_NAME);
            builder.field("max_determinized_states", 10);
        }
        builder.endObject();
    }
    builder.endObject();

    QueryBuilder queryBuilder = new QueryParseContext(createParser(builder)).parseInnerQueryBuilder();
    TooComplexToDeterminizeException e = expectThrows(TooComplexToDeterminizeException.class,
            () -> queryBuilder.toQuery(createShardContext()));
    assertThat(e.getMessage(), containsString("Determinizing [ac]*"));
    assertThat(e.getMessage(), containsString("would result in more than 10 states"));
}
项目:elasticsearch_my    文件:QueryStringQueryBuilderTests.java   
public void testToQueryRegExpQueryTooComplex() throws Exception {
    assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
    QueryStringQueryBuilder queryBuilder = queryStringQuery("/[ac]*a[ac]{50,200}/").defaultField(STRING_FIELD_NAME);

    TooComplexToDeterminizeException e = expectThrows(TooComplexToDeterminizeException.class,
            () -> queryBuilder.toQuery(createShardContext()));
    assertThat(e.getMessage(), containsString("Determinizing [ac]*"));
    assertThat(e.getMessage(), containsString("would result in more than 10000 states"));
}
项目:resource-query-parser    文件:TestQueryParser.java   
/** LUCENE-6677: make sure wildcard query respects maxDeterminizedStates. */
@Test
public void testWildcardMaxDeterminizedStates() throws Exception {
    QueryParser qp = new QueryParser("field", new MockAnalyzer(random()));
    qp.setMaxDeterminizedStates(10);
    expectThrows(TooComplexToDeterminizeException.class, () -> {
        qp.parse("a*aaaaaaa");
    });
}
项目:lucene-addons    文件:TestQueryParser.java   
public void testWildcardMaxDeterminizedStates() throws Exception {
  QueryParser qp = new QueryParser(FIELD, new MockAnalyzer(random()));
  qp.setMaxDeterminizedStates(10);
  try {
    qp.parse("a*aaaaaaa");
    fail("should have hit exception");
  } catch (TooComplexToDeterminizeException tctde) {
    // expected
  }
}