-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search API returns different results from Web UI #3239
Comments
How do you run the indexer ? Do you have projects enabled ? |
Both web UI and API went to the same OpenGrok instance, and using the same account. |
There is #3170, that's why I am asking about projects and indexer. |
|
I got more results from API than web UI. |
Tried to replicate this with 1.12.28 using AOSP source code and fulltext searching for 'google' (http://localhost:8080/source/api/v1/search?projects=AOSP&full=google&maxresults=200000). Using the API I got |
There is quite a difference how the search is done between web UI and the API. In API, the opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Line 181 in b4a9940
SuperIndexSearcher is a super class wrapping IndexSearcher for the purpose of "bumping" the related IndexReader after reindex so that newly indexed data can be displayed in search results) or opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Lines 202 to 203 in b4a9940
IndexSearcher is reused, with projects it is created from scratch. The query is created from the API arguments using opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Lines 154 to 160 in b4a9940
TopScoreDocCollector (Lucene). The results are then processed by SearchEngine#results() that can actually perform re-query, i.e. perform the search once again. This is also where any context is fetched from the index and source and added to the Hit objects that are then returned in a list. The search count comes from the hits length. The hits object is acquired here: opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Line 219 in b4a9940
|
The web UI uses the
IndexSearcher is acquired in SearchHelper#prepareExec() : opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java Lines 400 to 402 in b4a9940
executeQuery() : opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java Lines 478 to 479 in b4a9940
opengrok/opengrok-web/src/main/webapp/search.jsp Lines 227 to 228 in b4a9940
opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java Lines 109 to 110 in b4a9940
totalHits field as visible above. Compared to how the hits are extracted for the API in the SearchEngine , there is no collector involved.
The API uses Lucene's |
Describe the bug
The REST API (api/v1/search) returns different results from Web UI for the same query condition.
Environments:
To Reproduce
Steps to reproduce the behavior:
Searching from GUI, gets "Searched +full:google +refs:google (Results 25801 – 25802 of 25802) sorted by relevance"
But searching from REST API gets
Expected behavior
Web UI and API should return same results for the same search condition.
The text was updated successfully, but these errors were encountered: