Here are the main reasons for using the new updated API provided by GroupDocs.Search for Java from version 19.10:
Unified work with some similar entities to increase the intuitiveness of using API.
The architecture of the product has been revised and optimized, so that some functions will work faster.
Some entities have been renamed to improve code readability.
The changes made to the API are not too significant, so the migration will not be too difficult.
New functionality will not be added to the old API version, only to the new version.
How To Migrate?
The following code examples demonstrate changes in the use of the API.
Old coding style:
StringindexFolder="c:\\MyIndex\\";StringdocumentsFolder="c:\\MyDocuments\\";// Creating an index in the specified folder
Indexindex=newIndex(indexFolder);// Indexing documents from the specified folder
index.addToIndex(documentsFolder);// Creating a search parameters object
SearchParametersparameters=newSearchParameters();parameters.getFuzzySearch().setEnabled(true);// Enabling the fuzzy search
parameters.getFuzzySearch().setFuzzyAlgorithm(newTableDiscreteFunction(2));// Setting the number of possible differences for each word
// Searching in the index
SearchResultsresults=index.search("Happiness",parameters);if(results.getCount()>0){// Generating HTML-formatted text of a document with highlighted search results
index.highlightInText("c:\\Highlighted.html",results.get_Item(0));}
New coding style:
StringindexFolder="c:\\MyIndex\\";StringdocumentsFolder="c:\\MyDocuments\\";// Creating an index in the specified folder
Indexindex=newIndex(indexFolder);// Indexing documents from the specified folder
index.add(documentsFolder);// Creating a search options object
SearchOptionsoptions=newSearchOptions();options.getFuzzySearch().setEnabled(true);// Enabling the fuzzy search
options.getFuzzySearch().setFuzzyAlgorithm(newTableDiscreteFunction(2));// Setting the number of possible differences for each word
// Searching in the index
SearchResultresult=index.search("Happiness",options);if(result.getDocumentCount()>0){// Generating HTML-formatted text of a document with highlighted search results
index.highlight(result.getFoundDocument(0),newHtmlHighlighter(newFileOutputAdapter("c:\\Highlighted.html")));}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.