Simple Search for Java is not working

@atirtahir3
Please find them here : docs.zip (1.1 MB)

@Kushal.20,

We didn’t face any issue - See output.PNG (63.2 KB). What we did:

  • Deleted indexed files
  • Added new files (provided by you) in the document directory
  • Created index in directory
  • Performed simple search

@atirtahir3
Exactly, Its working perfectly at your end.
Is there any need to create index every time, when I need to search a new query ?
Where am I going wrong then? I followed the same steps too !
There seems to be an issue or two at my end, for sure, because that day too, I got it working for me after so much efforts.
Any idea ? Maybe some environment or config requirements ?
Is there any issue with the evaluation version ?

@Kushal.20,

Did you apply license properly? Even if you have a temporary license and it is applied properly, you will not face limitations. Make sure license is not expired.

You don’t have to create index every time until and unless you do some changes in the existing documents or you add new files in the documents directory.
Only in case of any change in the documents directory you have to update index. Currently, there’s some issue in updating the index and we are investigating this. So, you have to clear index directory and then create index again.

@atirtahir3
I don’t understand, what the issue is !
I am using the 30 days temporary licensed version for GroupDocs. The license is perfectly applied and I got it about an hour ago, approx, so I don’t think so there could be any case of expiry.

I am unable to understand the behaviour, sometimes it is working, for the previously searched terms, it’s working fine, on the other hand sometimes(mostly) it’s giving no response. I am following the same prescribed steps , still facing this unexpected behaviour.
I am searching for, ‘this’ and I have it in my documents, still getting no response.Is this how I need to struggle everytime for a new search ?
What to do in this case ?

@Kushal.20,

Let us elaborate you why you don’t get hits/output when you search ‘This’ word. You have to disable using stop words in your code as follows:

index.getIndexingSettings().setUseStopWords(false);
index.addToIndex(Utilities.DOCUMENTS_PATH);

Please go through this article for further clarification. Using stop words is enabled by default. So it doesn’t index words such as a, an, the, it, were, this etc. Hence, they don’t appear in search results.
Please disable them and try again (Set setUseStopWords to false).
You don’t have to do any struggle if you search any term that is already available in the docs. But when you update a doc or add new doc in the directory then you have to update index and perform search.

Below is the code to find out if the search term/word is Stop Word or not:

SearchResults searchResults = index.search(searchQuery);
System.out.println("Search result message: " + searchResults.getMessage());

@atirtahir3
Thanks for the information ! This is helpful.
I disabled these stop words, and it worked. :v: :slight_smile:
While, using index.update(), is giving an ArrayIndexOutOfBoundException. Following is the exception stack trace :

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
at com.groupdocs.search.et.a(Unknown Source)
at com.groupdocs.search.ay.a(Unknown Source)
at com.groupdocs.search.ay.dl(Unknown Source)
at com.groupdocs.search.ay.a(Unknown Source)
at com.groupdocs.search.bZ.o(Unknown Source)
at com.groupdocs.search.cm.b(Unknown Source)
at com.groupdocs.search.ch.a(Unknown Source)
at com.groupdocs.search.Index.a(Unknown Source)
at com.groupdocs.search.Index.a(Unknown Source)
at com.groupdocs.search.Index.update(Unknown Source)
at com.groupdocs.search.Index.update(Unknown Source)
at com.groupdocs.search.examples.Searching.simpleSearch(Searching.java:46)
at com.groupdocs.search.examples.MainClass.main(MainClass.java:17)

And, this is the code snippet :
public static void simpleSearch() {

	License lic = new License();
	lic.setLicense("xyz");
	
	// Create index
	Index index = new Index(Utilities.INDEX_PATH);
	index.getIndexingSettings().setUseStopWords(false);
	// Add documents to index
	index.addToIndex(Utilities.DOCUMENTS_PATH);
	
	// Search in index
	String searchQuery = "you";
	index.update();
	SearchResults searchResults = index.search(searchQuery);
	index.highlightInText(Utilities.DOCUMENT_TEXT_PATH, searchResults.get_Item(0));
	// Print results in the console
	for (DocumentResultInfo result : searchResults) {
		System.out.println(result.getHitCount() + " hits are in " + result.getFileName());
	}
}

This is solved as soon as I remove, index.update()

1 Like

@Kushal.20,

This is under investigation with ID : SEARCHJAVA-82. As we have any further update on this, you’ll be notified.

Okay. Thanks ! @atirtahir3

1 Like

@Kushal.20,

Let me share reason for this issue.
The problem occurs during re-indexing of password protected documents that are available in the directory. It will be fixed and you’ll be notified about that.
Right now, as a temporary solution, you can exclude password protected documents from indexing or provide the valid passwords for them.

1 Like

Hi ! @atirtahir3
Hope you are doing good !
Well, why is it so, that every new time simple search stops performing.
I came back to it today to try some new queries but it again stopped working. Everything is same, license is applied, I created index each time I ran it.
Please help me with this as it is very annoying. I am actually searching a for a fast and efficient document search tool. Groupdocs solved many of my requirements, but this behaviour each time, I am afraid !

@Kushal.20,

We are sorry for the inconvenience you are facing.

Can you please share string/word that you are trying to search and in which document such a word exists, we’ll then investigate it at our end. (assuming that you are searching on same document directory)?

@Kushal.20,

We are pleased to notify you that your reported issue SEARCHJAVA-82 is now resolved in version 19.5.1. Please download and integrate latest release of the API and share your feedback.