public class FuzzySearchOptions extends Object
Learn more
Modifier | Constructor and Description |
---|---|
protected |
FuzzySearchOptions()
Initializes a new instance of the
FuzzySearchOptions class. |
Modifier and Type | Method and Description |
---|---|
protected static FuzzySearchOptions |
create() |
protected static FuzzySearchOptions |
create(ArrayReader reader) |
protected static int |
getByteCount(FuzzySearchOptions options) |
boolean |
getConsiderTranspositions()
Gets a value indicating whether the fuzzy search algorithm must
consider transposition of two adjacent characters as a single mistake.
|
boolean |
getEnabled()
Gets a value indicating whether fuzzy search feature is enabled.
|
FuzzyAlgorithm |
getFuzzyAlgorithm()
Gets the fuzzy search algorithm.
|
protected static byte |
getMaxMistakeCount(FuzzySearchOptions options,
int termLength) |
boolean |
getOnlyBestResults()
Gets a value indicating whether only the best results will be returned.
|
byte |
getOnlyBestResultsRange()
Gets the maximum exceeding of the minimum number of mistakes that are found.
|
void |
setConsiderTranspositions(boolean value)
Sets a value indicating whether the fuzzy search algorithm must
consider transposition of two adjacent characters as a single mistake.
|
void |
setEnabled(boolean value)
Sets a value indicating whether fuzzy search feature is enabled.
|
void |
setFuzzyAlgorithm(FuzzyAlgorithm value)
Sets the fuzzy search algorithm.
|
void |
setOnlyBestResults(boolean value)
Sets a value indicating whether only the best results will be returned.
|
void |
setOnlyBestResultsRange(byte value)
Sets the maximum exceeding of the minimum number of mistakes that are found.
|
protected static void |
toByteArray(FuzzySearchOptions options,
ArrayWriter writer) |
protected FuzzySearchOptions()
FuzzySearchOptions
class.protected static FuzzySearchOptions create()
protected static FuzzySearchOptions create(ArrayReader reader)
public final boolean getEnabled()
false
.public final void setEnabled(boolean value)
false
.value
- A value indicating whether fuzzy search feature is enabled.public final FuzzyAlgorithm getFuzzyAlgorithm()
SimilarityLevel
and TableDiscreteFunction
.
The default value is an instance of SimilarityLevel
with a similarity level value of 0.5
.The example demonstrates how to set the fuzzy search algorithm.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
String query = "Einstein";
Index index = new Index(indexFolder); // Creating an index in the specified folder
index.add(documentsFolder); // Indexing documents from the specified folder
SearchOptions options = new SearchOptions();
options.getFuzzySearch().setEnabled(true); // Enabling the fuzzy search
options.getFuzzySearch().setFuzzyAlgorithm(new TableDiscreteFunction(1, new Step(5, 2), new Step(8, 3))); // Creating the fuzzy search algorithm
// This function specifies 1 as the maximum number of mistakes for words from 1 to 4 characters.
// It specifies 2 as the maximum number of mistakes for words from 5 to 7 characters.
// It specifies 3 as the maximum number of mistakes for words from 8 and more characters.
SearchResult result = index.search(query, options); // Search in index
public final void setFuzzyAlgorithm(FuzzyAlgorithm value)
SimilarityLevel
and TableDiscreteFunction
.
The default value is an instance of SimilarityLevel
with a similarity level value of 0.5
.value
- The fuzzy search algorithm.
The example demonstrates how to set the fuzzy search algorithm.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
String query = "Einstein";
Index index = new Index(indexFolder); // Creating an index in the specified folder
index.add(documentsFolder); // Indexing documents from the specified folder
SearchOptions options = new SearchOptions();
options.getFuzzySearch().setEnabled(true); // Enabling the fuzzy search
options.getFuzzySearch().setFuzzyAlgorithm(new TableDiscreteFunction(1, new Step(5, 2), new Step(8, 3))); // Creating the fuzzy search algorithm
// This function specifies 1 as the maximum number of mistakes for words from 1 to 4 characters.
// It specifies 2 as the maximum number of mistakes for words from 5 to 7 characters.
// It specifies 3 as the maximum number of mistakes for words from 8 and more characters.
SearchResult result = index.search(query, options); // Search in index
public final boolean getOnlyBestResults()
false
.true
if only the best results will be returned; otherwise false
.public final void setOnlyBestResults(boolean value)
false
.value
- true
if only the best results will be returned; otherwise false
.public final byte getOnlyBestResultsRange()
0
.public final void setOnlyBestResultsRange(byte value)
0
.value
- The maximum exceeding of the minimum number of mistakes found.public final boolean getConsiderTranspositions()
true
.true
if the fuzzy search algorithm considers transpositions; otherwise false
.public final void setConsiderTranspositions(boolean value)
true
.value:
- true
if the fuzzy search algorithm considers transpositions; otherwise false
.protected static byte getMaxMistakeCount(FuzzySearchOptions options, int termLength)
protected static int getByteCount(FuzzySearchOptions options)
protected static void toByteArray(FuzzySearchOptions options, ArrayWriter writer)