Exemple #1
0
func main() {
	si, _ := solr.NewSolrInterface("http://localhost:8983/solr", "collection1")

	query := solr.NewQuery()
	query.Q("title:add sucess 1")
	query.Start(0)
	query.Rows(15)
	s := si.Search(query)

	parser := &TestResultParser{}
	r, err := s.Result(parser)
	if err != nil {
		fmt.Println("Error when querying solr:", err.Error())
		return
	}

	fmt.Println(r.Results.Docs)
	fmt.Println(parser.original_response)

	parser2 := &InheritResultParser{}
	r2, err := s.Result(parser2)

	fmt.Println(r2.Results.Docs)

	fmt.Println(parser2.original_response)
}
// NewIndex creates a new solr index for the given solr url and index name.
// Metadata is ignored, we are using an automatic solr schema
func NewIndex(url, name string, md *index.Metadata) (*Index, error) {
	si, err := solr.NewSolrInterface(url, name)
	if err != nil {
		return nil, err
	}

	return &Index{
		si:   si,
		name: name,
		md:   md,
	}, nil

}