Example usage for org.apache.lucene.search RegexpQuery RegexpQuery

List of usage examples for org.apache.lucene.search RegexpQuery RegexpQuery

Introduction

In this page you can find the example usage for org.apache.lucene.search RegexpQuery RegexpQuery.

Prototype

public RegexpQuery(Term term, int flags, int maxDeterminizedStates) 

Source Link

Document

Constructs a query for terms matching term.

Usage

From source file:jp.scaleout.elasticsearch.plugins.queryparser.classic.QueryParserBase.java

License:Apache License

/**
 * Builds a new RegexpQuery instance// www  .j  av a  2 s.  c  om
 * @param regexp Regexp term
 * @return new RegexpQuery instance
 */
protected Query newRegexpQuery(Term regexp) {
    RegexpQuery query = new RegexpQuery(regexp, RegExp.ALL, maxDeterminizedStates);
    query.setRewriteMethod(multiTermRewriteMethod);
    return query;
}

From source file:org.codelibs.elasticsearch.index.mapper.StringFieldType.java

License:Apache License

@Override
public final Query regexpQuery(String value, int flags, int maxDeterminizedStates,
        MultiTermQuery.RewriteMethod method, QueryShardContext context) {
    failIfNotIndexed();/*w w  w .  j av  a 2  s.c  o  m*/
    RegexpQuery query = new RegexpQuery(new Term(name(), indexedValueForSearch(value)), flags,
            maxDeterminizedStates);
    if (method != null) {
        query.setRewriteMethod(method);
    }
    return query;
}

From source file:org.elasticsearch.index.mapper.MappedFieldType.java

License:Apache License

public Query regexpQuery(String value, int flags, int maxDeterminizedStates,
        @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) {
    if (numericType() != null) {
        throw new IllegalArgumentException(
                "Cannot use regular expression to filter numeric field [" + names.fullName + "]");
    }/*www . j  a v a2s.c  o  m*/
    if (this instanceof StringFieldType == false) {
        DEPRECATION_LOGGER.deprecated(
                "Regexp query on field [{}] of type [{}] is deprecated. The next version will only support it "
                        + "on text/keyword fields",
                names().fullName(), typeName());
    }

    RegexpQuery query = new RegexpQuery(createTerm(value), flags, maxDeterminizedStates);
    if (method != null) {
        query.setRewriteMethod(method);
    }
    return query;
}