com.groupdocs.search

Class IndexSettings



  • public class IndexSettings
    extends Object
    Represents the index settings that allow to customize the indexing operations.

    Learn more

    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
     
     
    • Constructor Detail

      • IndexSettings

        public IndexSettings()

        Initializes a new instance of the IndexSettings class.

    • Method Detail

      • getInMemoryIndex

        public final boolean getInMemoryIndex()

        Gets a value indicating whether the index is stored in memory or on disk.

        Returns:
        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:
        A value indicating whether to use stop words or not.
      • setUseStopWords

        public final void setUseStopWords(boolean value)

        Sets a value indicating whether to use stop words or not. The default value is true.

        Parameters:
        value - 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:
        The maximum number of indexing reports.
      • setMaxIndexingReportCount

        public final void setMaxIndexingReportCount(int value)

        Sets the maximum number of indexing reports. The default value is 5.

        Parameters:
        value - The maximum number of indexing reports.
      • getMaxSearchReportCount

        public final int getMaxSearchReportCount()

        Gets the maximum number of search reports. The default value is 10.

        Returns:
        The maximum number of search reports.
      • setMaxSearchReportCount

        public final void setMaxSearchReportCount(int value)

        Sets the maximum number of search reports. The default value is 10.

        Parameters:
        value - 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:
        A value indicating whether to use character replacements or not.
      • setUseCharacterReplacements

        public final void setUseCharacterReplacements(boolean value)

        Sets a value indicating whether to use character replacements or not. The default value is false.

        Parameters:
        value - A value indicating whether to use character replacements or not.
      • getAutoDetectEncoding

        public final boolean getAutoDetectEncoding()

        Gets a value indicating whether to detect encoding automatically or not. The default value is false.

        Returns:
        A value indicating whether to detect encoding automatically or not.
      • setAutoDetectEncoding

        public final void setAutoDetectEncoding(boolean value)

        Sets a value indicating whether to detect encoding automatically or not. The default value is false.

        Parameters:
        value - A value indicating whether to detect encoding automatically or not.
      • getUseRawTextExtraction

        public final boolean getUseRawTextExtraction()

        Gets a value indicating whether the raw mode is used for text extraction if possible. The default value is true. The raw mode can significantly increase the indexing speed, but normal mode improves the formatting of the extracted text.

        Returns:
        A value indicating whether the raw mode is used for text extraction if possible.
      • setUseRawTextExtraction

        public final void setUseRawTextExtraction(boolean value)

        Sets a value indicating whether the raw mode is used for text extraction if possible. The default value is true. The raw mode can significantly increase the indexing speed, but normal mode improves the formatting of the extracted text.

        Parameters:
        value - A value indicating whether the raw mode is used for text extraction if possible.
      • 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.

        Returns:
        The document filter.

        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

        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.

        Parameters:
        value - The document filter.

        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");
         
         
      • getTextStorageSettings

        public final TextStorageSettings getTextStorageSettings()

        Gets the text storage settings. The default value is null, which means that document texts are not stored.

        Returns:
        The text storage settings.

        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

        public final void setTextStorageSettings(TextStorageSettings value)

        Sets the text storage settings. The default value is null, which means that document texts are not stored.

        Parameters:
        value - The text storage settings.

        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.

        Returns:
        The index type.
      • setIndexType

        public final void setIndexType(IndexType value)

        Sets the index type. The default value is GroupDocs.Search.Options.IndexType.NormalIndex.

        Parameters:
        value - The index type.
      • getSearchThreads

        public final NumberOfThreads getSearchThreads()

        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:
        The number of threads used for the search.
      • setSearchThreads

        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.

        Parameters:
        value - The number of threads used for the search.
      • getCustomExtractors

        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.

        Returns:
        The custom extractor collection.
      • getLogger

        public final ILogger getLogger()

        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:
        A logger that is used for logging events and errors in the index.
      • setLogger

        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.

        Parameters:
        value - A logger that is used for logging events and errors in the index.
      • isReadOnly

        protected static boolean isReadOnly(IndexSettings settings)