-
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 def return more than needed #3748
Comments
I assume that the search in the UI is performed by using the 'Definition' field in the search form, correct ? |
Tried that with search for the |
Getting the results of search to the client is actually pretty complex. There are major differences in how the search is done in the UI and via the API. I will try to summarize it here for future reference since I don't know whole lot about it myself. When going via the API, it starts in Now, for the context (sic!) of this bug, opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Lines 467 to 476 in 33eb38a
This method then uses opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java Line 364 in 33eb38a
Hit objects to the list for the non-definition tokens in dumpRest() : opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java Lines 404 to 406 in 33eb38a
opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java Lines 420 to 424 in 33eb38a
opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java Line 435 in 33eb38a
|
Searching from the UI is a tad different as it uses different search wraper: opengrok/opengrok-web/src/main/webapp/search.jsp Lines 81 to 86 in 701f162
It builds IndexSearcher in prepareExec() and calls search() in executeQuery - the approach is similar to what SearchEngine does for the API based search.
The results are then presented via
Results#printPlain() . Similarly to SearchEngine used by the API, the SearchHelper uses Context (at least in our case of plaintext) however different method: opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java Lines 265 to 270 in 701f162
OGKUnifiedHighlighter that extends Lucene's UnifiedHighlighter to display the results. It uses the query to filter the results, I think.
So, while opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java Lines 274 to 279 in 701f162
isDefSearch properly: opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java Lines 292 to 299 in 701f162
|
Looking at #2732, this bug could be fixed if we merged that PR since it replaces the offending |
Hey,
My Opengrok version is 1-5-11
When I try to search for definitions I got each appears on the file the variable is defined there, for example,
https://opengrok.checkpoint.com:8443/source/api/v1/search?def=ws_http2_stream_error_action&projects=ivory_main
This is what I get, it should return only line 105, on UI it works and jumps me direct to line 105
The text was updated successfully, but these errors were encountered: