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

how to go about inserting []jsonDocs ( Update() returns success but solr logs show failures) #55

Open
msonawane opened this issue Feb 28, 2020 · 1 comment

Comments

@msonawane
Copy link

msonawane commented Feb 28, 2020

I already have json docs as string

following code snippet is used to construct a valid json string.

func StoreInSolr(sc *solr.SolrInterface, docs []string) (*solr.SolrUpdateResponse, error) {
	params := &url.Values{}
	params.Add("commit", "true")
	var lines []string
	for _, doc := range docs {
		if len(strings.TrimSpace(doc)) == 0 {
			continue
		}
		lines = append(lines, doc)
	}
	data := fmt.Sprintf("[%s]\n", strings.Join(lines, ","))
	fmt.Printf("data: %+v\n", data)
	resp, err := sc.Update(data, params)
	return resp, err
}
both resp and err indicate success:
&solr.SolrUpdateResponse{Success:true, Result:map[string]interface {}{"responseHeader":map[string]interface {}{"QTime":3, "status":0}}}, err: <nil>

but on solr debug logs i get

o.a.s.h.l.JsonLoader Can't have a value here. Unexpected STRING at [1]

This has to do with json string format but json is valid.

any pointers appreciated .

@msonawane msonawane changed the title how to go about inserting []jsonDocs ( Update() returns success but solr logs show failure )s) how to go about inserting []jsonDocs ( Update() returns success but solr logs show failures) Feb 28, 2020
@vanng822
Copy link
Owner

Hi @msonawane
It is long time ago I use Solr. I use responseHeader.status as success indicator and can not answer why solr return 0 instead of 400. Don't know if any other here can answer that question? else more likely you can find the answer at Solr-project itself.
Do you have entire response from Solr?
How come that you have it as string already?

Else maybe this can help you?
https://github.com/vanng822/go-solr/blob/master/solr/solr.go#L170
https://github.com/vanng822/go-solr/blob/master/solr/solr.go#L162

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

No branches or pull requests

2 participants