20
20
/*
21
21
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
22
22
* Portions copyright (c) 2011 Jens Elkner.
23
- * Portions Copyright (c) 2017-2019 , Chris Fraire <[email protected] >.
23
+ * Portions Copyright (c) 2017-2020 , Chris Fraire <[email protected] >.
24
24
*/
25
25
package org .opengrok .indexer .web ;
26
26
@@ -401,7 +401,7 @@ public SearchHelper executeQuery() {
401
401
// one single definition term AND we have exactly one match AND there
402
402
// is only one definition of that symbol in the document that matches.
403
403
boolean uniqueDefinition = false ;
404
- if (isSingleDefinitionSearch && hits != null && hits .length == 1 ) {
404
+ if (isCrossRefSearch && isSingleDefinitionSearch && hits != null && hits .length == 1 ) {
405
405
Document doc = searcher .doc (hits [0 ].doc );
406
406
if (doc .getField (QueryBuilder .TAGS ) != null ) {
407
407
byte [] rawTags = doc .getField (QueryBuilder .TAGS ).binaryValue ().bytes ;
@@ -412,9 +412,7 @@ public SearchHelper executeQuery() {
412
412
}
413
413
}
414
414
}
415
- // @TODO fix me. I should try to figure out where the exact hit is
416
- // instead of returning a page with just _one_ entry in....
417
- if (uniqueDefinition && hits != null && hits .length > 0 && isCrossRefSearch ) {
415
+ if (uniqueDefinition ) {
418
416
redirect = contextPath + Prefix .XREF_P
419
417
+ Util .URIEncodePath (searcher .doc (hits [0 ].doc ).get (QueryBuilder .PATH ))
420
418
+ '#' + Util .URIEncode (((TermQuery ) query ).getTerm ().text ());
0 commit comments