Example usage for org.apache.lucene.search.suggest.document FuzzyCompletionQuery DEFAULT_MIN_FUZZY_LENGTH

List of usage examples for org.apache.lucene.search.suggest.document FuzzyCompletionQuery DEFAULT_MIN_FUZZY_LENGTH

Introduction

In this page you can find the example usage for org.apache.lucene.search.suggest.document FuzzyCompletionQuery DEFAULT_MIN_FUZZY_LENGTH.

Prototype

int DEFAULT_MIN_FUZZY_LENGTH

To view the source code for org.apache.lucene.search.suggest.document FuzzyCompletionQuery DEFAULT_MIN_FUZZY_LENGTH.

Click Source Link

Document

The default minimum length of the key before any edits are allowed.

Usage

From source file:org.elasticsearch.index.mapper.completion.CompletionFieldMapperTests.java

License:Apache License

public void testFuzzyQueryType() throws Exception {
    String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
            .startObject("completion").field("type", "completion").endObject().endObject().endObject()
            .endObject().string();/* w ww . ja v a2 s. c  o m*/

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("completion");
    CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
    Query prefixQuery = completionFieldMapper.fieldType().fuzzyQuery("co",
            Fuzziness.fromEdits(FuzzyCompletionQuery.DEFAULT_MAX_EDITS),
            FuzzyCompletionQuery.DEFAULT_NON_FUZZY_PREFIX, FuzzyCompletionQuery.DEFAULT_MIN_FUZZY_LENGTH,
            Operations.DEFAULT_MAX_DETERMINIZED_STATES, FuzzyCompletionQuery.DEFAULT_TRANSPOSITIONS,
            FuzzyCompletionQuery.DEFAULT_UNICODE_AWARE);
    assertThat(prefixQuery, instanceOf(FuzzyCompletionQuery.class));
}

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

License:Apache License

public void testFuzzyQueryType() throws Exception {
    String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
            .startObject("completion").field("type", "completion").endObject().endObject().endObject()
            .endObject().string();/*from w  ww  .j  a  va 2s.c o m*/

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1",
            new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("completion");
    CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
    Query prefixQuery = completionFieldMapper.fieldType().fuzzyQuery("co",
            Fuzziness.fromEdits(FuzzyCompletionQuery.DEFAULT_MAX_EDITS),
            FuzzyCompletionQuery.DEFAULT_NON_FUZZY_PREFIX, FuzzyCompletionQuery.DEFAULT_MIN_FUZZY_LENGTH,
            Operations.DEFAULT_MAX_DETERMINIZED_STATES, FuzzyCompletionQuery.DEFAULT_TRANSPOSITIONS,
            FuzzyCompletionQuery.DEFAULT_UNICODE_AWARE);
    assertThat(prefixQuery, instanceOf(FuzzyCompletionQuery.class));
}