Skip to content

Commit bbbbadd

Browse files
committed
provide tag in search results
1 parent ab58547 commit bbbbadd

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

apiary.apib

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -576,19 +576,32 @@ The repository path is relative to source root.
576576
+ Body
577577

578578
{
579-
"time": 13,
580-
"resultCount": 35,
579+
"time": 1229,
580+
"resultCount": 8,
581581
"startDocument": 0,
582-
"endDocument": 0,
582+
"endDocument": 7,
583583
"results": {
584-
"/opengrok/test/org/opensolaris/opengrok/history/hg-export-renamed.txt": [{
585-
"line": "# User Vladimir <b>Kotal</b> &lt;Vladimir.<b>Kotal</b>@oracle.com&gt;",
586-
"lineNumber": "19"
587-
},{
588-
"line": "# User Vladimir <b>Kotal</b> &lt;Vladimir.<b>Kotal</b>@oracle.com&gt;",
589-
"lineNumber":"29"
590-
}]
584+
"/onnv/usr/src/lib/libnisdb/db_pickle.cc": [
585+
{
586+
"line": "pickle_file::<b>transfer</b>(pptr p, bool_t (*f) (XDR*, pptr))",
587+
"lineNumber": "106",
588+
"tag": "function in pickle_file"
589+
}
590+
],
591+
"/onnv/usr/src/cmd/pools/poold/com/sun/solaris/service/pools/Resource.java": [
592+
{
593+
"line": "\tpublic void <b>transfer</b>(Resource donor, long qty) throws PoolsException",
594+
"lineNumber": "93",
595+
"tag": "method in Resource"
596+
},
597+
{
598+
"line": "\tpublic void <b>transfer</b>(Resource donor, List components)",
599+
"lineNumber": "110",
600+
"tag": "method in Resource"
601+
}
602+
],
591603
}
604+
}
592605

593606
## Suggester [/suggest{?projects,field,caret,full,defs,refs,path,hist,type}]
594607

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SearchController.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.web.api.v1.controller;
@@ -91,7 +91,8 @@ public SearchResult search(
9191
Map<String, List<SearchHit>> hits = engine.search(req, projects, startDocIndex, maxResults)
9292
.stream()
9393
.collect(Collectors.groupingBy(Hit::getPath,
94-
Collectors.mapping(h -> new SearchHit(h.getLine(), h.getLineno()), Collectors.toList())));
94+
Collectors.mapping(h -> new SearchHit(h.getLine(), h.getLineno(), h.getTag()),
95+
Collectors.toList())));
9596

9697
long duration = Duration.between(startTime, Instant.now()).toMillis();
9798

@@ -220,9 +221,12 @@ private static class SearchHit {
220221

221222
private final String lineNumber;
222223

223-
private SearchHit(final String line, final String lineNumber) {
224+
private final String tag;
225+
226+
private SearchHit(final String line, final String lineNumber, final String tag) {
224227
this.line = line;
225228
this.lineNumber = lineNumber;
229+
this.tag = tag;
226230
}
227231

228232
public String getLine() {
@@ -232,6 +236,10 @@ public String getLine() {
232236
public String getLineNumber() {
233237
return lineNumber;
234238
}
239+
240+
public String getTag() {
241+
return tag;
242+
}
235243
}
236244

237245
}

0 commit comments

Comments
 (0)