Search in sources :

Example 1 with MultiMatchQueryType

use of org.elasticsearch.index.query.MultiMatchQueryType in project crate by crate.

the class MatchQueries method multiMatch.

public static Query multiMatch(QueryShardContext queryShardContext, @Nullable String matchType, Map<String, Float> fieldNames, String queryString, Map<String, Object> options) {
    MultiMatchQueryType type = MatchQueries.getType(matchType);
    ParsedOptions parsedOptions = OptionParser.parse(type, options);
    MultiMatchQuery multiMatchQuery = new MultiMatchQuery(queryShardContext);
    Float tieBreaker = parsedOptions.tieBreaker();
    if (tieBreaker != null) {
        multiMatchQuery.setTieBreaker(tieBreaker);
    }
    String analyzer = parsedOptions.analyzer();
    if (analyzer != null) {
        multiMatchQuery.setAnalyzer(analyzer);
    }
    multiMatchQuery.setCommonTermsCutoff(parsedOptions.commonTermsCutoff());
    multiMatchQuery.setFuzziness(parsedOptions.fuzziness());
    multiMatchQuery.setFuzzyPrefixLength(parsedOptions.prefixLength());
    multiMatchQuery.setFuzzyRewriteMethod(parsedOptions.rewriteMethod());
    multiMatchQuery.setMaxExpansions(parsedOptions.maxExpansions());
    multiMatchQuery.setPhraseSlop(parsedOptions.phraseSlop());
    multiMatchQuery.setTranspositions(parsedOptions.transpositions());
    multiMatchQuery.setZeroTermsQuery(parsedOptions.zeroTermsQuery());
    multiMatchQuery.setOccur(parsedOptions.operator());
    return multiMatchQuery.parse(type, fieldNames, queryString, parsedOptions.minimumShouldMatch());
}
Also used : MultiMatchQuery(org.elasticsearch.index.search.MultiMatchQuery) MultiMatchQueryType(org.elasticsearch.index.query.MultiMatchQueryType)

Example 2 with MultiMatchQueryType

use of org.elasticsearch.index.query.MultiMatchQueryType in project crate by crate.

the class MatchQueries method singleMatch.

public static Query singleMatch(QueryShardContext queryShardContext, String fieldName, String queryString, @Nullable String matchType, @Nullable Map<String, Object> options) {
    MultiMatchQueryType type = getType(matchType);
    ParsedOptions parsedOptions = OptionParser.parse(type, options);
    MatchQuery matchQuery = new MatchQuery(queryShardContext);
    if (parsedOptions.analyzer() != null) {
        matchQuery.setAnalyzer(parsedOptions.analyzer());
    }
    matchQuery.setCommonTermsCutoff(parsedOptions.commonTermsCutoff());
    matchQuery.setFuzziness(parsedOptions.fuzziness());
    matchQuery.setFuzzyPrefixLength(parsedOptions.prefixLength());
    matchQuery.setFuzzyRewriteMethod(parsedOptions.rewriteMethod());
    matchQuery.setMaxExpansions(parsedOptions.maxExpansions());
    matchQuery.setPhraseSlop(parsedOptions.phraseSlop());
    matchQuery.setTranspositions(parsedOptions.transpositions());
    matchQuery.setZeroTermsQuery(parsedOptions.zeroTermsQuery());
    matchQuery.setOccur(parsedOptions.operator());
    MatchQuery.Type matchQueryType = type.matchQueryType();
    return matchQuery.parse(matchQueryType, fieldName, queryString);
}
Also used : MultiMatchQuery(org.elasticsearch.index.search.MultiMatchQuery) MatchQuery(org.elasticsearch.index.search.MatchQuery) MultiMatchQueryType(org.elasticsearch.index.query.MultiMatchQueryType)

Aggregations

MultiMatchQueryType (org.elasticsearch.index.query.MultiMatchQueryType)2 MultiMatchQuery (org.elasticsearch.index.search.MultiMatchQuery)2 MatchQuery (org.elasticsearch.index.search.MatchQuery)1