Beispiel #1
0
func (q *BasicQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error) {
	notop := false
	if (q.term.mod == OpUnaryNot) || (q.term.mod == OpUnaryPro) {
		notop = true
	}
	// TODO: add field == ""

	searchTerm := fmt.Sprintf("%s:%s", q.field, q.term.term)
	i := indexer.GetIndex()
	res, err := i.SearchResults(searchTerm, notop, curRes)

	return res, err
}
Beispiel #2
0
func (q *BasicQuery) SearchIndex(idxName string) (map[string]indexer.Document, error) {
	notop := false
	if (q.term.mod == OpUnaryNot) || (q.term.mod == OpUnaryPro) {
		notop = true
	}
	i := indexer.GetIndex()
	if q.field == "" {
		res, err := i.SearchText(idxName, string(q.term.term), notop)
		return res, err
	}
	searchTerm := fmt.Sprintf("%s:%s", q.field, q.term.term)
	res, err := i.Search(idxName, searchTerm, notop)

	return res, err
}
Beispiel #3
0
func (q *GroupedQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error) {
	tmpRes := make([]groupQueryHolder, len(q.terms))
	for i, v := range q.terms {
		tmpRes[i].op = v.mod
		notop := false
		if v.mod == OpUnaryNot || v.mod == OpUnaryPro {
			notop = true
		}
		searchTerm := fmt.Sprintf("%s:%s", q.field, v.term)
		ix := indexer.GetIndex()
		r, err := ix.SearchResults(searchTerm, notop, curRes)
		if err != nil {
			return nil, err
		}
		tmpRes[i].res = r
	}
	res, err := mergeResults(tmpRes)
	return res, err
}
Beispiel #4
0
func (q *RangeQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error) {
	i := indexer.GetIndex()
	res, err := i.SearchResultsRange(string(q.field), string(q.start), string(q.end), q.inclusive, curRes)
	return res, err
}
Beispiel #5
0
func (q *RangeQuery) SearchIndex(idxName string) (map[string]indexer.Document, error) {
	i := indexer.GetIndex()
	res, err := i.SearchRange(idxName, string(q.field), string(q.start), string(q.end), q.inclusive)
	return res, err
}