summaryrefslogtreecommitdiff
path: root/system/api/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'system/api/search.go')
-rw-r--r--system/api/search.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/system/api/search.go b/system/api/search.go
index ae6ac1c..c743d9f 100644
--- a/system/api/search.go
+++ b/system/api/search.go
@@ -44,7 +44,7 @@ func searchContentHandler(res http.ResponseWriter, req *http.Request) {
// execute search for query provided, if no index for type send 404
matches, err := db.SearchType(t, q)
if err == db.ErrNoSearchIndex {
- res.WriteHeader(http.StatusBadRequest)
+ res.WriteHeader(http.StatusNotFound)
return
}
if err != nil {
@@ -61,6 +61,11 @@ func searchContentHandler(res http.ResponseWriter, req *http.Request) {
return
}
+ // if we have matches, push the first as its matched by relevance
+ if len(bb) > 0 {
+ push(res, req, it, bb[0])
+ }
+
var result = []json.RawMessage{}
for i := range bb {
result = append(result, bb[i])