The example demonstrates a typical usage of the class.
```
String indexFolder = "c:\\MyIndex\\";
IndexSettings settings = new IndexSettings();
settings.setIndexType(IndexType.CompactIndex); // Setting the index type
Index index = new Index(indexFolder, settings); // Creating an index
```
Sets a logger that is used for logging events and errors in the index.
IndexSettings()
public IndexSettings()
Initializes a new instance of the IndexSettings class.
getInMemoryIndex()
public final boolean getInMemoryIndex()
Gets a value indicating whether the index is stored in memory or on disk.
Returns:
boolean - A value indicating whether the index is stored in memory or on disk.
getUseStopWords()
public final boolean getUseStopWords()
Gets a value indicating whether to use stop words or not. The default value is true .
Returns:
boolean - A value indicating whether to use stop words or not.
setUseStopWords(boolean value)
public final void setUseStopWords(boolean value)
Sets a value indicating whether to use stop words or not. The default value is true .
Parameters:
Parameter
Type
Description
value
boolean
A value indicating whether to use stop words or not.
getMaxIndexingReportCount()
public final int getMaxIndexingReportCount()
Gets the maximum number of indexing reports. The default value is 5 .
Returns:
int - The maximum number of indexing reports.
setMaxIndexingReportCount(int value)
public final void setMaxIndexingReportCount(int value)
Sets the maximum number of indexing reports. The default value is 5 .
Parameters:
Parameter
Type
Description
value
int
The maximum number of indexing reports.
getMaxSearchReportCount()
public final int getMaxSearchReportCount()
Gets the maximum number of search reports. The default value is 10 .
Returns:
int - The maximum number of search reports.
setMaxSearchReportCount(int value)
public final void setMaxSearchReportCount(int value)
Sets the maximum number of search reports. The default value is 10 .
Parameters:
Parameter
Type
Description
value
int
The maximum number of search reports.
getUseCharacterReplacements()
public final boolean getUseCharacterReplacements()
Gets a value indicating whether to use character replacements or not. The default value is false .
Returns:
boolean - A value indicating whether to use character replacements or not.
setUseCharacterReplacements(boolean value)
public final void setUseCharacterReplacements(boolean value)
Sets a value indicating whether to use character replacements or not. The default value is false .
Parameters:
Parameter
Type
Description
value
boolean
A value indicating whether to use character replacements or not.
getDocumentFilter()
public final DocumentFilter getDocumentFilter()
Gets a document filter. The DocumentFilter works on the inclusion logic. Use the DocumentFilter class for creation a document filter instance. The default value is null , which means that all added documents are indexed.
The example demonstrates how to set the document filter.
```
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating a filter that skips documents with extensions '.doc', '.docx', '.rtf'
IndexSettings settings = new IndexSettings();
DocumentFilter fileExtensionFilter = DocumentFilter.createFileExtension(".doc", ".docx", ".rtf"); // Creating file extension filter
DocumentFilter invertedFilter = DocumentFilter.createNot(fileExtensionFilter); // Inverting file extension filter
settings.setDocumentFilter(invertedFilter);
// Creating an index in the specified folder
Index index = new Index(indexFolder, settings);
// Indexing documents
index.add(documentsFolder);
// Searching
SearchResult result = index.search("Einstein");
```
setDocumentFilter(DocumentFilter value)
public final void setDocumentFilter(DocumentFilter value)
Sets a document filter. The DocumentFilter works on the inclusion logic. Use the GroupDocs.Search.Options.DocumentFilter class for creation of a document filter instances. The default value is null , which means that all added documents are indexed.
The example demonstrates how to set the text storage settings.
```
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating index settings instance
IndexSettings settings = new IndexSettings();
settings.setTextStorageSettings(new TextStorageSettings(Compression.High)); // Setting high compression level for the index text storage
// Creating an index in the specified folder
Index index = new Index(indexFolder, settings);
// Indexing documents
index.add(documentsFolder);
// Searching
SearchResult result = index.search("Einstein");
```
setTextStorageSettings(TextStorageSettings value)
public final void setTextStorageSettings(TextStorageSettings value)
Sets the text storage settings. The default value is null , which means that document texts are not stored.
The example demonstrates how to set the text storage settings.
```
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating index settings instance
IndexSettings settings = new IndexSettings();
settings.setTextStorageSettings(new TextStorageSettings(Compression.High)); // Setting high compression level for the index text storage
// Creating an index in the specified folder
Index index = new Index(indexFolder, settings);
// Indexing documents
index.add(documentsFolder);
// Searching
SearchResult result = index.search("Einstein");
```
|
getIndexType()
public final IndexType getIndexType()
Gets the index type. The default value is GroupDocs.Search.Options.IndexType.NormalIndex .
Gets the number of threads used for the search. The default value is GroupDocs.Search.Options.NumberOfThreads.Default , which means that the search will be performed using the number of threads equal to the number of processor cores.
Returns:NumberOfThreads - The number of threads used for the search.
setSearchThreads(NumberOfThreads value)
public final void setSearchThreads(NumberOfThreads value)
Sets the number of threads used for the search. The default value is GroupDocs.Search.Options.NumberOfThreads.Default , which means that the search will be performed using the number of threads equal to the number of processor cores.
public final CustomExtractorCollection getCustomExtractors()
Gets the custom extractor collection. The full example of implementing a custom extractor is presented in documentation for GroupDocs.Search.Common.IFieldExtractor interface.
Gets a logger that is used for logging events and errors in the index. Note that the logger is not saved and must be created and assigned each time the index is created or loaded.
Returns:ILogger - A logger that is used for logging events and errors in the index.
setLogger(ILogger value)
public final void setLogger(ILogger value)
Sets a logger that is used for logging events and errors in the index. Note that the logger is not saved and must be created and assigned each time the index is created or loaded.