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

es.Create error :status: 400, failed: [mapper_parsing_exception], reason: failed to parse #892

Open
gif-gif opened this issue Jul 25, 2024 · 0 comments

Comments

@gif-gif
Copy link

gif-gif commented Jul 25, 2024

es, err := elasticsearch.NewTypedClient(elasticsearch.Config{
		Addresses: []string{"http://127.0.0.1:9200"},
		Username:  "es",
		Password:  "123456",
	})

	if err != nil {
		golog.Error("Error creating elasticsearch:" + err.Error())
		return
	}

	document := struct {
		Name string `json:"name"`
	}{
		"go-elasticsearch",
	}
	b, _ := json.Marshal(document)
	str := string(b)
	golog.Debug("doc:" + str)

	res, err := es.Create("index1", "doc_id6").Document(str).Refresh(refresh.True).Do(context.Background())
	if err != nil {
		golog.Error("es.Create error :" + err.Error())
		return
	}

	golog.WithTag("elasticsearch").Info(res)

running error is : status: 400, failed: [mapper_parsing_exception], reason: failed to parse
Document func not surport json string? only go struct ? why ? thanks gays.

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

1 participant