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

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

Introduction

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

Prototype

boolean DEFAULT_TRANSPOSITIONS

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

Click Source Link

Document

The default transposition value passed to LevenshteinAutomata

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();//from ww  w  .  java  2 s .  com

    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();/* ww  w.jav a 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));
}