Beispiel #1
0
func search(user content.User, searchIndex readeef.SearchIndex, query, highlight, feedId string) (resp responseError) {
	resp = newResponse()

	if strings.HasPrefix(feedId, "tag:") {
		tag := user.Repo().Tag(user)
		tag.Value(data.TagValue(feedId[4:]))

		tag.Highlight(highlight)
		resp.val["Articles"], resp.err = tag.Query(query, searchIndex.Index), tag.Err()
	} else {
		if id, err := strconv.ParseInt(feedId, 10, 64); err == nil {
			f := user.FeedById(data.FeedId(id))
			resp.val["Articles"], resp.err = f.Query(query, searchIndex.Index), f.Err()
		} else {
			user.Highlight(highlight)
			resp.val["Articles"], resp.err = user.Query(query, searchIndex.Index), user.Err()
		}
	}

	return
}