1//  Copyright (c) 2014 Couchbase, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// 		http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package search
16
17import (
18	"context"
19	"time"
20
21	index "github.com/blevesearch/bleve_index_api"
22)
23
24type Collector interface {
25	Collect(ctx context.Context, searcher Searcher, reader index.IndexReader) error
26	Results() DocumentMatchCollection
27	Total() uint64
28	MaxScore() float64
29	Took() time.Duration
30	SetFacetsBuilder(facetsBuilder *FacetsBuilder)
31	FacetResults() FacetResults
32}
33
34// DocumentMatchHandler is the type of document match callback
35// bleve will invoke during the search.
36// Eventually, bleve will indicate the completion of an ongoing search,
37// by passing a nil value for the document match callback.
38// The application should take a copy of the hit/documentMatch
39// if it wish to own it or need prolonged access to it.
40type DocumentMatchHandler func(hit *DocumentMatch) error
41
42type MakeDocumentMatchHandlerKeyType string
43
44var MakeDocumentMatchHandlerKey = MakeDocumentMatchHandlerKeyType(
45	"MakeDocumentMatchHandlerKey")
46
47// MakeDocumentMatchHandler is an optional DocumentMatchHandler
48// builder function which the applications can pass to bleve.
49// These builder methods gives a DocumentMatchHandler function
50// to bleve, which it will invoke on every document matches.
51type MakeDocumentMatchHandler func(ctx *SearchContext) (
52	callback DocumentMatchHandler, loadID bool, err error)
53