Free Support Forum - groupdocs.com

Synonym search


#1

Hi,

I am using GroupDocs.search for java for synonym search.

My requirement is that I have a data set, with all the synonyms for a word and I have to return the data in case any synonym is matched
Example:
small,little,tiny
speed,quick,fast

In case I search for small or little I should get small in the output.

I have tried below code:
public class Searching {
public static void synonymSearch() {
Index index = new Index(Utilities.INDEX_PATH);
index.getDictionaries().getSynonymDictionary().importDictionary(Utilities.SYNONYM_FILE_PATH);
index.addToIndex(Utilities.DOCUMENTS_PATH);
SearchParameters parameters = new SearchParameters();
parameters.setUseSynonymSearch(true);
parameters.setSearchDocumentFilter(null);

	String searchString = "virtual";
	SearchResults searchResults = index.search(searchString, parameters);
	// Print found results in the console
	for (DocumentResultInfo documentResultInfo : searchResults) {
		System.out.println(documentResultInfo.getFileName() + "\n");
	}
}

}

But I am getting filename in the output instead of data.

Please help me.

Thanks,
Madhur


#2

@madhur2928,

You can get data as well. Below is the code to achieve this:

SearchResults searchResults = index.search(searchString, parameters);
index.highlightInText("D:\\highlighted.html", searchResults.get_Item(0)); 

This is what highlighted.zip (1.1 KB) you will get in the output. If you see the code below,

searchResults.get_Item(0)

0 is the file hit number. For example, if there are 10 files, and search result hit is found in the very first file then its hit number is 0.


#3

Thanks for the reply.

My problem statement is that I have a data set of synonyms in csv format.
Example:
big,large,huge
small,tiny,less

User will provide the input, I have to search for it inside my data set and have to return first matching element.

example if I search for big or large my output will be big

Is this possible?? If yes please help me in this.

Thanks,
Madhur


#4

@madhur2928,

We are investigating this scenario. Your investigation ticket ID is SEARCHJAVA-97. As we have any further update, you’ll be notified.