public class SearchOptions extends Object
Learn more
Constructor and Description |
---|
SearchOptions()
Initializes a new instance of the
SearchOptions class. |
Modifier and Type | Method and Description |
---|---|
protected static SearchOptions |
create(ArrayReader reader) |
protected static SearchOptions |
create(byte[] array) |
protected static SearchOptions |
createInstance(byte[] array) |
Cancellation |
getCancellation()
Gets the operation cancellation object.
|
DateFormatCollection |
getDateFormats()
Gets the collection of date formats for date range search.
|
protected static DocumentFilter |
getDocumentFilter(SearchOptions options) |
FuzzySearchOptions |
getFuzzySearch()
Gets the fuzzy search options.
|
KeyboardLayoutCorrectorOptions |
getKeyboardLayoutCorrector()
Gets the keyboard layout corrector options.
|
int |
getMaxOccurrenceCountPerTerm()
Gets the maximum number of occurrences of each term in a search query.
|
int |
getMaxTotalOccurrenceCount()
Gets the maximum total number of occurrences of all terms in a search query.
|
ISearchDocumentFilter |
getSearchDocumentFilter()
Gets the search document filter.
|
protected static int |
getSerializedLength(SearchOptions options) |
SpellingCorrectorOptions |
getSpellingCorrector()
Gets the spelling corrector options.
|
boolean |
getUseCaseSensitiveSearch()
Gets the flag of case sensitive search.
|
boolean |
getUseHomophoneSearch()
Gets the flag of use homophones in search.
|
boolean |
getUseSynonymSearch()
Gets the flag of use synonyms in search.
|
boolean |
getUseWordFormsSearch()
Gets the flag of use different word forms in search.
|
boolean |
isChunkSearch()
Gets the flag of search by chunks.
|
protected static void |
serialize(SearchOptions options,
ArrayWriter writer) |
void |
setCancellation(Cancellation value)
Sets the operation cancellation object.
|
void |
setChunkSearch(boolean value)
Sets the flag of search by chunks.
|
protected static void |
setFuzzySearch(SearchOptions options,
FuzzySearchOptions value) |
void |
setMaxOccurrenceCountPerTerm(int value)
Sets the maximum number of occurrences of each term in a search query.
|
void |
setMaxTotalOccurrenceCount(int value)
Sets the maximum total number of occurrences of all terms in a search query.
|
void |
setSearchDocumentFilter(ISearchDocumentFilter value)
Sets the search document filter.
|
void |
setUseCaseSensitiveSearch(boolean value)
Sets the flag of case sensitive search.
|
void |
setUseHomophoneSearch(boolean value)
Sets the flag of use homophones in search.
|
void |
setUseSynonymSearch(boolean value)
Sets the flag of use synonyms in search.
|
void |
setUseWordFormsSearch(boolean value)
Sets the flag of use different word forms in search.
|
protected static byte[] |
toByteArray(SearchOptions options) |
public SearchOptions()
SearchOptions
class.public final boolean getUseSynonymSearch()
false
.public final void setUseSynonymSearch(boolean value)
false
.value
- The flag of use synonyms in search.public final boolean getUseHomophoneSearch()
false
.public final void setUseHomophoneSearch(boolean value)
false
.value
- The flag of use homophones in search.public final boolean getUseWordFormsSearch()
false
.public final void setUseWordFormsSearch(boolean value)
false
.value
- The flag of use different word forms in search.public final FuzzySearchOptions getFuzzySearch()
protected static void setFuzzySearch(SearchOptions options, FuzzySearchOptions value)
public final SpellingCorrectorOptions getSpellingCorrector()
public final KeyboardLayoutCorrectorOptions getKeyboardLayoutCorrector()
public final boolean getUseCaseSensitiveSearch()
false
.public final void setUseCaseSensitiveSearch(boolean value)
false
.value
- The flag of case sensitive search.public final int getMaxTotalOccurrenceCount()
500000
.public final void setMaxTotalOccurrenceCount(int value)
500000
.value
- The maximum total number of occurrences.public final int getMaxOccurrenceCountPerTerm()
100000
.public final void setMaxOccurrenceCountPerTerm(int value)
100000
.value
- The maximum number of occurrences of each term in a search query.public final DateFormatCollection getDateFormats()
The example demonstrates how to set the date formats for the search.
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.getDateFormats().clear(); // Removing default date formats
DateFormatElement[] elements = new DateFormatElement[] {
DateFormatElement.getMonthTwoDigits(),
DateFormatElement.getDayOfMonthTwoDigits(),
DateFormatElement.getYearFourDigits(),
};
// Creating a date format pattern 'MM/dd/yyyy'
com.groupdocs.search.DateFormat dateFormat = new com.groupdocs.search.DateFormat(elements, "/");
options.getDateFormats().addItem(dateFormat);
SearchResult result = index.search(query, options); // Search in index
public final boolean isChunkSearch()
false
.public final void setChunkSearch(boolean value)
false
.value
- The flag of search by chunks.public final ISearchDocumentFilter getSearchDocumentFilter()
SearchDocumentFilter
works on the inclusion logic.
Use SearchDocumentFilter
class for creation of a search document filter instances.
The default value is null
, which means that all found documents will be returned.The example demonstrates how to set the document filter.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments1\\";
// Creating an index in the specified folder
Index index = new Index(indexFolder);
// Indexing documents
index.add(documentsFolder);
// Creating a search document filter that skips documents with extensions '.doc', '.docx', '.rtf'
SearchOptions options = new SearchOptions();
ISearchDocumentFilter fileExtensionFilter = SearchDocumentFilter.createFileExtension(".doc", ".docx", ".rtf"); // Creating file extension filter
ISearchDocumentFilter invertedFilter = SearchDocumentFilter.createNot(fileExtensionFilter); // Inverting file extension filter
options.setSearchDocumentFilter(invertedFilter);
// Search in index
SearchResult result = index.search("Einstein", options);
public final void setSearchDocumentFilter(ISearchDocumentFilter value)
SearchDocumentFilter
works on the inclusion logic.
Use SearchDocumentFilter
class for creation of a search document filter instances.
The default value is null
, which means that all found documents will be returned.value
- The search document filter.
The example demonstrates how to set the document filter.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments1\\";
// Creating an index in the specified folder
Index index = new Index(indexFolder);
// Indexing documents
index.add(documentsFolder);
// Creating a search document filter that skips documents with extensions '.doc', '.docx', '.rtf'
SearchOptions options = new SearchOptions();
ISearchDocumentFilter fileExtensionFilter = SearchDocumentFilter.createFileExtension(".doc", ".docx", ".rtf"); // Creating file extension filter
ISearchDocumentFilter invertedFilter = SearchDocumentFilter.createNot(fileExtensionFilter); // Inverting file extension filter
options.setSearchDocumentFilter(invertedFilter);
// Search in index
SearchResult result = index.search("Einstein", options);
public final Cancellation getCancellation()
null
.public final void setCancellation(Cancellation value)
null
.value
- The operation cancellation object.protected static DocumentFilter getDocumentFilter(SearchOptions options)
protected static int getSerializedLength(SearchOptions options)
protected static byte[] toByteArray(SearchOptions options)
protected static void serialize(SearchOptions options, ArrayWriter writer)
protected static SearchOptions createInstance(byte[] array)
protected static SearchOptions create(byte[] array)
protected static SearchOptions create(ArrayReader reader)