Last active
January 25, 2025 18:45
Search with Aliases in Document using Java. For more information, please follow link: https://kb.groupdocs.com/search/java/search-with-aliases-in-document-using-java/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.groupdocs.search.Index; | |
import com.groupdocs.search.licenses.License; | |
import com.groupdocs.search.results.SearchResult; | |
public class SearchwithAliasesinDocumentusingJava { | |
public static void main(String[] args) throws Exception { | |
// Apply the license to remove the restrictions | |
// imposed by the Search library | |
License license = new License(); | |
license.setLicense("GroupDocs.Search.lic"); | |
// The path where the index will be stored | |
String indexFolder = "c:\\MyIndex\\"; | |
// The folder containing the documents you want to search | |
String documentsFolder = "c:\\MyDocuments\\"; | |
// Creating an index in the specified folder | |
Index index = new Index(indexFolder); | |
// Indexing documents from the specified folder | |
index.add(documentsFolder); | |
// Adding aliases to the alias dictionary | |
index.getDictionaries().getAliasDictionary().add("t", "(theory OR relativity)"); | |
index.getDictionaries().getAliasDictionary().add("e", "(Einstein OR Albert)"); | |
// Search in the index | |
SearchResult result = index.search("@t OR @e"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment