Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352434 - [Help][Search] "Nothing found" if more than 1000 matches
Summary: [Help][Search] "Nothing found" if more than 1000 matches
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.7.1   Edit
Assignee: Chris Goldthorpe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 359886 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-07-19 06:39 EDT by Holger Voormann CLA
Modified: 2011-10-05 16:59 EDT (History)
4 users (show)

See Also:
cgold: review+
ChrisAustin: review+


Attachments
Patch for bug 352434 (999 bytes, patch)
2011-07-19 06:45 EDT, Holger Voormann CLA
cgold: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Voormann CLA 2011-07-19 06:39:26 EDT
If there are more than 1000 matches then "Nothing found." is displayed in the Search Result tab/frame, e.g. search for "eclipse" at http://help.eclipse.org:
<http://help.eclipse.org/indigo/index.jsp?tab=search&searchWord=eclipse>

Should: 
In Search Result tab/frame display "500 matches in All topics: Change scope" and all these 500 matches one below the other instead of "Nothing found." only, similar to (query is "eclipse.help OR eclipse.core OR eclipse.jdt" instead of "eclipse"):
<http://help.eclipse.org/indigo/index.jsp?tab=search&searchWord=eclipse.help+OR+eclipse.core+OR+eclipse.jdt>

Side note: if there are more than 500 matches then the title text should start with something like "More than 500 matches" instead of  "500 matches" only.

Stack trace:
java.lang.ArrayIndexOutOfBoundsException: 1000
	at org.eclipse.help.internal.search.LocalSearchManager.asList(LocalSearchManager.java:161)
	at org.eclipse.help.internal.search.SearchIndex.search(SearchIndex.java:628)
	at org.eclipse.help.internal.search.LocalSearchManager.search(LocalSearchManager.java:591)
	at org.eclipse.help.internal.search.SearchManager.searchLocal(SearchManager.java:103)
	at org.eclipse.help.internal.search.SearchManager.search(SearchManager.java:94)
	at org.eclipse.help.internal.webapp.data.SearchData.loadSearchResults(SearchData.java:430)
	at org.eclipse.help.internal.webapp.data.SearchData.readSearchResults(SearchData.java:166)
	at org.eclipse.help.internal.webapp.data.SearchData.<init>(SearchData.java:112)
	at org.apache.jsp.advanced.searchView_jsp._jspService(searchView_jsp.java:80)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        ...
Comment 1 Holger Voormann CLA 2011-07-19 06:45:08 EDT
Created attachment 199890 [details]
Patch for bug 352434

Problem:
Because in org.apache.lucene.search.TopDocs totalHits is less(!) or equal than scoreDocs.length. Examples:
* totalHits=0     and scoreDocs.length=0
* totalHits=861   and scoreDocs.length=861
* totalHits=13884 and scoreDocs.length=1000 will cause following ArrayIndexOutOfBoundsException: 1000

Solution:
In org.eclipse.help.internal.search.LocalSearchManager.asList(TopDocs, IndexSearcher) use topDocs.scoreDocs.length instead of topDocs.totalHits
Comment 2 Chris Goldthorpe CLA 2011-07-19 18:02:25 EDT
Thanks for the patch! I will include this in 3.7.1.
Comment 3 Chris Goldthorpe CLA 2011-07-21 18:22:44 EDT
I verified that this could be reproduced in the SDK by searching for "the" , if the quotes are included in the search expression.
Comment 4 Chris Goldthorpe CLA 2011-08-15 18:41:14 EDT
Patch committed to HEAD.
Comment 5 Chris Goldthorpe CLA 2011-08-15 18:51:34 EDT
Patch committed to 3.7 Maintenance Stream, Fixed.
Comment 6 Chris Austin CLA 2011-08-16 15:44:28 EDT
Looks good to me.
Comment 7 Helmut J. Haigermoser CLA 2011-08-23 06:21:57 EDT
CQ:WIND00293269

Thanks for fixing this one! :)
Helmut
Comment 8 Chris Goldthorpe CLA 2011-08-24 16:42:32 EDT
Verified in M20110824-0800
Comment 9 Chris Goldthorpe CLA 2011-10-05 16:59:21 EDT
*** Bug 359886 has been marked as a duplicate of this bug. ***