// QueryIndex - Make a query on the given index
// Use the passed function to build the document into the wished struct
Make a query on the given index
Use the passed function to build the document into the wished struct
// QueryIndex - Make a query on the given index // Use the passed function to build the document into the wished struct
func QueryIndex(index bleve.Index, query Queries.ITamalouQuery, buildIndexable func(*document.Document) Indexable) ([]Indexable, error) {
	strQuery := Queries.BuildIndexQuery(query)
	indexQuery := bleve.NewQueryStringQuery(strQuery)
	search := bleve.NewSearchRequest(indexQuery)
	searchResults, err := index.Search(search)
	if err != nil {
		return nil, fmt.Errorf("Error querying index\n	Error ==> %v\n	Index ==> %v", err, index)
	}
	var results []Indexable
	for _, hit := range searchResults.Hits {
		doc, err := index.Document(hit.ID)
		if err != nil {
			return nil, fmt.Errorf("Error building indexable\n	Error ==> %v\n	Index ==> %v", err, index)
		}
		results = append(results, buildIndexable(doc))
	}
	return results, nil
}
func QueryIndex ( index bleve . Index , query Queries . ITamalouQuery , buildIndexable func ( * document . Document ) Indexable ) ( [ ] Indexable , error ) { strQuery := Queries . BuildIndexQuery ( query ) indexQuery := bleve . NewQueryStringQuery ( strQuery ) search := bleve . NewSearchRequest ( indexQuery ) searchResults , err := index . Search ( search ) if err != nil { return nil , fmt . Errorf ( " \n \n " , err , index ) } var results [ ] Indexable for _ , hit := range searchResults . Hits { doc , err := index . Document ( hit . ID ) if err != nil { return nil , fmt . Errorf ( " \n \n " , err , index ) } results = append ( results , buildIndexable ( doc ) ) } return results , nil }
Make a query on the given index
Use the passed function to build the document into the wished struct
Make a query on the given index Use the passed function to build the document into the wished struct