diff options
author | Areek Zillur <areek.zillur@elasticsearch.com> | 2015-11-02 20:14:33 -0500 |
---|---|---|
committer | Areek Zillur <areek.zillur@elasticsearch.com> | 2015-11-07 17:46:27 -0500 |
commit | 96c9849f5ac279e5d4904ccbfe7266aaad639b25 (patch) | |
tree | ba2eeb3fb7d28ede0f85163a5f62f861796bec13 /core/src/main/java/org/elasticsearch/search/suggest | |
parent | dd1c687ace953c82f3671363dd077c1c99b1fc8e (diff) |
added FuzzyOptionsBuilder javadocs and cleanups
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/suggest')
4 files changed, 24 insertions, 5 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java index bb4c386553..ed9f0a1ddd 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java @@ -54,7 +54,7 @@ public class CompletionSuggester extends Suggester<CompletionSuggestionContext> final CompletionSuggestionContext suggestionContext, final IndexSearcher searcher, CharsRefBuilder spare) throws IOException { final CompletionFieldMapper.CompletionFieldType fieldType = suggestionContext.getFieldType(); if (fieldType == null) { - throw new ElasticsearchException("field [" + suggestionContext.getField() + "] is not a completion field"); + throw new IllegalArgumentException("field [" + suggestionContext.getField() + "] is not a completion field"); } CompletionSuggestion completionSuggestion = new CompletionSuggestion(name, suggestionContext.getSize()); spare.copyUTF8Bytes(suggestionContext.getText()); @@ -71,13 +71,12 @@ public class CompletionSuggester extends Suggester<CompletionSuggestionContext> contexts = fieldType.getContextMappings().getNamedContexts(suggestDoc.getContexts()); } // collect payloads - Map<String, List<Object>> payload = Collections.emptyMap(); + final Map<String, List<Object>> payload = new HashMap<>(0); Set<String> payloadFields = suggestionContext.getPayloadFields(); if (!payloadFields.isEmpty()) { int readerIndex = ReaderUtil.subIndex(suggestDoc.doc, searcher.getIndexReader().leaves()); LeafReaderContext subReaderContext = searcher.getIndexReader().leaves().get(readerIndex); int subDocId = suggestDoc.doc - subReaderContext.docBase; - payload = new LinkedHashMap<>(payloadFields.size()); for (String field : payloadFields) { MappedFieldType payloadFieldType = suggestionContext.getMapperService().smartNameFieldType(field); if (payloadFieldType != null) { diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java index 9fcb86c6c1..8e08b5a315 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java @@ -127,26 +127,48 @@ public class CompletionSuggestionBuilder extends SuggestBuilder.SuggestionBuilde return this; } + /** + * Returns the maximum number of edits + */ int getEditDistance() { return editDistance; } + /** + * Returns if transpositions option is set + * + * if transpositions is set, then swapping one character for another counts as one edit instead of two. + */ boolean isTranspositions() { return transpositions; } + + /** + * Returns the length of input prefix after which edits are applied + */ int getFuzzyMinLength() { return fuzzyMinLength; } + /** + * Returns the minimum length of the input prefix required to apply any edits + */ int getFuzzyPrefixLength() { return fuzzyPrefixLength; } + /** + * Returns if all measurements (like edit distance, transpositions and lengths) are in unicode code + * points (actual letters) instead of bytes. + */ boolean isUnicodeAware() { return unicodeAware; } + /** + * Returns the maximum automaton states allowed for fuzzy expansion + */ int getMaxDeterminizedStates() { return maxDeterminizedStates; } diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionContext.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionContext.java index dffbc7753a..87ea90cdda 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionContext.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionContext.java @@ -26,7 +26,6 @@ import org.elasticsearch.index.mapper.core.CompletionFieldMapper; import org.elasticsearch.search.suggest.Suggester; import org.elasticsearch.search.suggest.SuggestionSearchContext; import org.elasticsearch.search.suggest.completion.context.CategoryQueryContext; -import org.elasticsearch.search.suggest.completion.context.ContextMapping; import org.elasticsearch.search.suggest.completion.context.ContextMappings; import java.util.List; diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java index bc92cde722..0f56de55f7 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java @@ -64,7 +64,6 @@ public abstract class ContextMapping implements ToXContent { * @param name name of context mapping */ protected ContextMapping(Type type, String name) { - super(); this.type = type; this.name = name; } |