com.groupdocs.search.options

Class SearchOptions



  • public class SearchOptions
    extends Object

    Provides options for search operation.

    Learn more

    • Constructor Detail

      • SearchOptions

        public SearchOptions()

        Initializes a new instance of the SearchOptions class.

    • Method Detail

      • getUseSynonymSearch

        public final boolean getUseSynonymSearch()

        Gets the flag of use synonyms in search. The default value is false.

        Returns:
        The flag of use synonyms in search.
      • setUseSynonymSearch

        public final void setUseSynonymSearch(boolean value)

        Sets the flag of use synonyms in search. The default value is false.

        Parameters:
        value - The flag of use synonyms in search.
      • getUseHomophoneSearch

        public final boolean getUseHomophoneSearch()

        Gets the flag of use homophones in search. The default value is false.

        Returns:
        The flag of use homophones in search.
      • setUseHomophoneSearch

        public final void setUseHomophoneSearch(boolean value)

        Sets the flag of use homophones in search. The default value is false.

        Parameters:
        value - The flag of use homophones in search.
      • getUseWordFormsSearch

        public final boolean getUseWordFormsSearch()

        Gets the flag of use different word forms in search. The default value is false.

        Returns:
        The flag of use different word forms in search.
      • setUseWordFormsSearch

        public final void setUseWordFormsSearch(boolean value)

        Sets the flag of use different word forms in search. The default value is false.

        Parameters:
        value - The flag of use different word forms in search.
      • getFuzzySearch

        public final FuzzySearchOptions getFuzzySearch()

        Gets the fuzzy search options.

        Returns:
        The fuzzy search options.
      • getSpellingCorrector

        public final SpellingCorrectorOptions getSpellingCorrector()

        Gets the spelling corrector options.

        Returns:
        The spelling corrector options.
      • getKeyboardLayoutCorrector

        public final KeyboardLayoutCorrectorOptions getKeyboardLayoutCorrector()

        Gets the keyboard layout corrector options.

        Returns:
        The keyboard layout corrector options.
      • getUseCaseSensitiveSearch

        public final boolean getUseCaseSensitiveSearch()

        Gets the flag of case sensitive search. The default value is false.

        Returns:
        The flag of case sensitive search.
      • setUseCaseSensitiveSearch

        public final void setUseCaseSensitiveSearch(boolean value)

        Sets the flag of case sensitive search. The default value is false.

        Parameters:
        value - The flag of case sensitive search.
      • getMaxTotalOccurrenceCount

        public final int getMaxTotalOccurrenceCount()

        Gets the maximum total number of occurrences of all terms in a search query. The default value is 500000.

        Returns:
        The maximum total number of occurrences.
      • setMaxTotalOccurrenceCount

        public final void setMaxTotalOccurrenceCount(int value)

        Sets the maximum total number of occurrences of all terms in a search query. The default value is 500000.

        Parameters:
        value - The maximum total number of occurrences.
      • getMaxOccurrenceCountPerTerm

        public final int getMaxOccurrenceCountPerTerm()

        Gets the maximum number of occurrences of each term in a search query. The default value is 100000.

        Returns:
        The maximum number of occurrences of each term in a search query.
      • setMaxOccurrenceCountPerTerm

        public final void setMaxOccurrenceCountPerTerm(int value)

        Sets the maximum number of occurrences of each term in a search query. The default value is 100000.

        Parameters:
        value - The maximum number of occurrences of each term in a search query.
      • getDateFormats

        public final DateFormatCollection getDateFormats()

        Gets the collection of date formats for date range search. The default date formats are 'dd.MM.yyyy', 'MM/dd/yyyy', and 'yyyy-MM-dd'.

        Returns:
        The collection of date formats for date range search.

        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
         
      • isChunkSearch

        public final boolean isChunkSearch()

        Gets the flag of search by chunks. The default value is false.

        Returns:
        The flag of search by chunks.
      • setChunkSearch

        public final void setChunkSearch(boolean value)

        Sets the flag of search by chunks. The default value is false.

        Parameters:
        value - The flag of search by chunks.
      • getSearchDocumentFilter

        public final ISearchDocumentFilter getSearchDocumentFilter()

        Gets the search document filter. 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.

        Returns:
        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);
         
      • setSearchDocumentFilter

        public final void setSearchDocumentFilter(ISearchDocumentFilter value)

        Sets the search document filter. 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.

        Parameters:
        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);
         
      • getCancellation

        public final Cancellation getCancellation()

        Gets the operation cancellation object. The default value is null.

        Returns:
        The operation cancellation object.
      • setCancellation

        public final void setCancellation(Cancellation value)

        Sets the operation cancellation object. The default value is null.

        Parameters:
        value - The operation cancellation object.
      • getSerializedLength

        protected static int getSerializedLength(SearchOptions options)
      • toByteArray

        protected static byte[] toByteArray(SearchOptions options)
      • createInstance

        protected static SearchOptions createInstance(byte[] array)