mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 01:36:18 +00:00
#241: search suggestions
This commit is contained in:
@@ -367,11 +367,12 @@ public class DocumentResource extends BaseResource {
|
||||
|
||||
TagDao tagDao = new TagDao();
|
||||
PaginatedList<DocumentDto> paginatedList = PaginatedLists.create(limit, offset);
|
||||
List<String> suggestionList = Lists.newArrayList();
|
||||
SortCriteria sortCriteria = new SortCriteria(sortColumn, asc);
|
||||
DocumentCriteria documentCriteria = parseSearchQuery(search);
|
||||
documentCriteria.setTargetIdList(getTargetIdList(null));
|
||||
try {
|
||||
AppContext.getInstance().getIndexingHandler().findByCriteria(paginatedList, documentCriteria, sortCriteria);
|
||||
AppContext.getInstance().getIndexingHandler().findByCriteria(paginatedList, suggestionList, documentCriteria, sortCriteria);
|
||||
} catch (Exception e) {
|
||||
throw new ServerException("SearchError", "Error searching in documents", e);
|
||||
}
|
||||
@@ -402,8 +403,15 @@ public class DocumentResource extends BaseResource {
|
||||
.add("file_count", documentDto.getFileCount())
|
||||
.add("tags", tags));
|
||||
}
|
||||
|
||||
JsonArrayBuilder suggestions = Json.createArrayBuilder();
|
||||
for (String suggestion : suggestionList) {
|
||||
suggestions.add(suggestion);
|
||||
}
|
||||
|
||||
response.add("total", paginatedList.getResultCount())
|
||||
.add("documents", documents);
|
||||
.add("documents", documents)
|
||||
.add("suggestions", suggestions);
|
||||
|
||||
return Response.ok().entity(response.build()).build();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim
|
||||
.then(function (data) {
|
||||
$scope.documents = data.documents;
|
||||
$scope.totalDocuments = data.total;
|
||||
$scope.suggestions = data.suggestions;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
<!-- Search (simple and advanced) -->
|
||||
<div class="row search-dropdown-anchor">
|
||||
<div class="col-xs-12 input-group">
|
||||
<input type="search" class="form-control" ng-attr-placeholder="{{ 'document.search' | translate }}" ng-model="search" />
|
||||
<input type="search" class="form-control"
|
||||
uib-typeahead="suggestion for suggestion in suggestions"
|
||||
typeahead-focus-first="false"
|
||||
ng-attr-placeholder="{{ 'document.search' | translate }}" ng-model="search" />
|
||||
<span class="input-group-addon btn" ng-click="openSearch()">
|
||||
<div uib-dropdown
|
||||
auto-close="disabled" is-open="searchOpened" dropdown-append-to="searchDropdownAnchor">
|
||||
|
||||
Reference in New Issue
Block a user