Example usage for org.apache.lucene.queryparser.flexible.standard CommonQueryParserConfiguration setAllowLeadingWildcard

List of usage examples for org.apache.lucene.queryparser.flexible.standard CommonQueryParserConfiguration setAllowLeadingWildcard

Introduction

In this page you can find the example usage for org.apache.lucene.queryparser.flexible.standard CommonQueryParserConfiguration setAllowLeadingWildcard.

Prototype

public void setAllowLeadingWildcard(boolean allowLeadingWildcard);

Source Link

Document

Set to true to allow leading wildcard characters.

Usage

From source file:org.exist.indexing.lucene.LuceneIndexWorker.java

License:Open Source License

protected void setOptions(Properties options, CommonQueryParserConfiguration parser) throws ParseException {
    if (options == null)
        return;// ww w . ja  va2  s . c  o  m
    String option = options.getProperty(OPTION_DEFAULT_OPERATOR);
    if (option != null && parser instanceof QueryParserBase) {
        if (DEFAULT_OPERATOR_OR.equals(option))
            ((QueryParserBase) parser).setDefaultOperator(QueryParser.OR_OPERATOR);
        else
            ((QueryParserBase) parser).setDefaultOperator(QueryParser.AND_OPERATOR);
    }
    option = options.getProperty(OPTION_LEADING_WILDCARD);
    if (option != null)
        parser.setAllowLeadingWildcard(option.equalsIgnoreCase("yes"));
    option = options.getProperty(OPTION_PHRASE_SLOP);
    if (option != null) {
        try {
            int slop = Integer.parseInt(option);
            parser.setPhraseSlop(slop);
        } catch (NumberFormatException e) {
            throw new ParseException("value for option " + OPTION_PHRASE_SLOP + " needs to be a number");
        }
    }
    option = options.getProperty(OPTION_FILTER_REWRITE);
    if (option != null) {
        if (option.equalsIgnoreCase("yes"))
            parser.setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
        else
            parser.setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE);
    }
}

From source file:org.tallison.lucene.queryparser.spans.TestQPTestBaseSpanQuery.java

License:Apache License

@Override
public void assertWildcardQueryEquals(String query, String result, boolean allowLeadingWildcard)
        throws Exception {
    CommonQueryParserConfiguration cqpC = getParserConfig(null);
    cqpC.setAllowLeadingWildcard(allowLeadingWildcard);
    assertQueryEquals(cqpC, "field", query, result);
}