Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gadelkareem
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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


for k, r := range resp.Response {
switch k {
case "response":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we think that we still have some kind of response that is corresponding to collection. My thought is that we should skip this and put everything i Payload. We do very generic stuff here and let application go for specific parsing

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look like suggester didn't have response?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we think that we still have some kind of response that is corresponding to collection. My thought is that we should skip this and put everything i Payload. We do very generic stuff here and let application go for specific parsing

Since it is still part of Solr responds then it be parsed using the same methods in the library. Only if it is new response then it is left up to the developer to parse it.

Look like suggester didn't have response?

No the suggest response would look something like this:

{
   "responseHeader":{
      "status":0,
      "QTime":2
   },
   "suggest":{
      "suggester":{
         "keyword":{
            "numFound":0,
            "suggestions":[

            ]
         }
      }
   }
}

Copy link
Owner

@vanng822 vanng822 Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you're sure that response always contains documents response, ie

"response":{"numFound":1,"start":0,"maxScore":2.3025851,"docs":[ {...}]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly yes unless Solr change their response scheme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants