vanng822 / go-solr

Solr client in Go, core admin, add docs, update, delete, search and more
MIT License
69 stars 42 forks source link

Handle user-specific requests that are not already handled #49

Open gadelkareem opened 5 years ago

gadelkareem commented 5 years ago

Every time a developer adds a new request handler with a new endpoint will need to create its own parser which is a bit of work. Therefore, I suggest to add such handler to allow developers to painlessly handle non standard requests. While errors and status is already handled by the library. ex:

        q := solr.NewQuery()
    q.AddParam("suggest.q", query)
    q.AddParam("suggest", "true")
    q.Rows(0)
    s := r.Search(q)
    res, err := s.Any("suggest", nil)
    if err != nil {
        return
    }

    fmt.Printf("%+v",  res.Payload) //we should have everything we need 
    s1, ok := res.Payload["suggest"].(map[string]interface{})
    if ok {
        //dig some more..
    }
vanng822 commented 4 years ago

Do you have any use case for this or you just think that people may need it? For me if you are using something special then it is fair that you build something your own. People can call directly to Resource(...) and process the response in the way as they want. That was my thought of Resource

gadelkareem commented 4 years ago

@vanng822 yes as I mentioned in the example above the /suggest endpoint is not covered by the library yet.