Open hanabishi opened 8 years ago
(just random comments & mental notes (pun intended))
Can't really locate the problem. Without Lucene-search, an exact match will mean an immediate redirect, thus results can be returned as "?query=xxxxx" and it will do another search in the database and redirect to "xxxxx" when clicked. That has been changed with lucenesearch into returning a list with links directly to said place (without doing another search).
By adding the following kludge, things work as expected
public class SearchItemWrapper extends FreeTextSearchItem {
....
@Override
public String getSearchUrl() {
try {
java.lang.reflect.Field f = item.getClass().getDeclaredField("val$searchable");
f.setAccessible(true);
SearchableModelObject o = (SearchableModelObject) f.get(item);
if (o instanceof Run) {
Run<?, ?> build = (Run<?, ?>) o;
return build.getParent().getParent().getUrl() + build.getParent().getSearchUrl() + build.getSearchUrl();
} else if (o instanceof ItemGroup) {
ItemGroup<?> build = (ItemGroup<?>) o;
return build.getUrl();
} else if (o instanceof Job) {
Job build = (Job) o;
return build.getParent().getUrl() + build.getSearchUrl();
}
} catch (Exception e) {
e.printStackTrace();
}
}
except that there are ~5-10 implementers of SearchModelObject in core, and an unknown amount outside of core.
Reimplementing the standard way didn't go as planned in the first attempt, and imho has no real advantage.
The Jenkins link from the default Jenkins search plugin when standing on a build and searching for a build number will result in a broken link When standing in job and searching for a build on that job. https:///1955