parent
5486c519b6
commit
69d69e4516
|
@ -401,6 +401,12 @@ func MultiSearch(req *SearchRequest, indexes ...Index) (*SearchResult, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// for now stop on any error
|
||||
// FIXME offer other behaviors
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// merge just concatenated all the hits
|
||||
// now lets clean it up
|
||||
|
||||
|
@ -426,11 +432,5 @@ func MultiSearch(req *SearchRequest, indexes ...Index) (*SearchResult, error) {
|
|||
sr.Facets.Fixup(name, fr.Size)
|
||||
}
|
||||
|
||||
// for now stop on any error
|
||||
// FIXME offer other behaviors
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sr, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package bleve
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/blevesearch/bleve/document"
|
||||
)
|
||||
|
||||
// TestMultiSearchAllError
|
||||
// reproduces https://github.com/blevesearch/bleve/issues/126
|
||||
func TestMultiSearchAllError(t *testing.T) {
|
||||
ei1 := &errIndex{err: fmt.Errorf("deliberate error")}
|
||||
ei2 := &errIndex{err: fmt.Errorf("deliberate errro")}
|
||||
sr := NewSearchRequest(NewTermQuery("test"))
|
||||
_, err := MultiSearch(sr, ei1, ei2)
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// errIndex is an Index impl for which all operations
|
||||
// return the configured error value
|
||||
type errIndex struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (i *errIndex) Index(id string, data interface{}) error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Delete(id string) error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Batch(b *Batch) error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Document(id string) (*document.Document, error) {
|
||||
return nil, i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) DocCount() (uint64, error) {
|
||||
return 0, i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Search(req *SearchRequest) (*SearchResult, error) {
|
||||
return nil, i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Fields() ([]string, error) {
|
||||
return nil, i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) DumpAll() chan interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *errIndex) DumpDoc(id string) chan interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *errIndex) DumpFields() chan interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *errIndex) Close() error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) Mapping() *IndexMapping {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *errIndex) Stats() *IndexStat {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *errIndex) GetInternal(key []byte) ([]byte, error) {
|
||||
return nil, i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) SetInternal(key, val []byte) error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
func (i *errIndex) DeleteInternal(key []byte) error {
|
||||
return i.err
|
||||
}
|
Loading…
Reference in New Issue