-
Notifications
You must be signed in to change notification settings - Fork 13
Add support for json params object #28
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
Conversation
|
@stevenferrer looks like you have to approve something to be able to run the GitHub workflows |
|
Hi @takanuva15, thanks for submitting a PR! From the looks if it, the
type Paramer interface {
BuildParam() M
}
type SpellCheckParam struct {
q string
// other fields...
}
func (p *SpellCheckParam) BuildParam() M {
m := M{}
if p.q != "" {
m["spellcheck.q"] = f.q
}
// other fields...
return m
}
func (p *SpellCheckParam) Q(q string) *SpellCheckParam {
p.q = q
return p
}
// other fields...
func (q *Query) Params(params ...Paramer) *Query {
q.params = params
return q
} |
|
Hi, that definitely makes sense for structured stuff like facets, but the issue with "params" is that it can be literally any query parameter you want - solr just treats it as if you were appending it directly to the url using the standard http-param format. In the example solr gives: They were able to configure For my situation, I'm dealing with a large enterprise codebase with a lot of complex queries. As one example, I need to dereference arbitrary parameters: I can't just inline everything due to the existing logging/debugging/maintenance infrastructure that our team has around these requests, so I need the params block as above. With the new queryStr := "{!boost b=$xyzCompanyCustomDateboostFn v=$speciallyGeneratedQueryStr defType=dismax}"
query := solr.NewQuery(queryStr).
Params(solr.M{
"speciallyGeneratedQueryStr": "specialQueryTerms",
"xyzCompanyCustomDateboostFn": "recip(ms(NOW/HOUR,myDateField),...)",
})
res, err := s.solrClient.Query(context.Background(), "myColl", query)To make it work with (To be fair, the params object I added in the unit test is oversimplified, so I'll go back in and update it with the above use case) |
|
Thanks for sharing your use case! With that, I'd agree that it's simpler to keep this field a map. I'll suggest to add a separate test-case to demonstrate a realistic use of this field, thanks 👍 |
|
Hi, PR is now updated with another test case using parameter dereferencing syntax |
stevenferrer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
|
Thanks! It looks like there's no new tag for this on the GitHub repo yet - can we add one for importing into go.mod? |
Add support for json params object
closes #26