예제 #1
0
func (i *Indexer) QueryString(query string) ([]string, error) {
	var documents []string
	for _, store := range i.stores {
		docs, err := store.QueryString(query)
		if err != nil {
			return documents, err
		}
		documents = append(documents, docs...)
	}
	return documents, nil
}
예제 #2
0
func (sh *storeHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	query := req.FormValue("q")
	if query == "" {
		http.Error(w, "Missing parameter: q", http.StatusBadRequest)
		return
	}
	for _, store := range sh.stores {
		docs, err := store.QueryString(query)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		for _, doc := range docs {
			_, err := fmt.Fprintln(w, doc)
			if err != nil {
				return
			}
		}
	}
}