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

Bulk data failure #8058

Closed
wjfang90 opened this issue Mar 25, 2024 · 2 comments
Closed

Bulk data failure #8058

wjfang90 opened this issue Mar 25, 2024 · 2 comments

Comments

@wjfang90
Copy link

wjfang90 commented Mar 25, 2024

NEST/Elasticsearch.Net version 6.5.1:

Elasticsearch version 6.5.4

Description of the problem including expected versus actual behavior:
I used client.Bulk() method to save data to ES, responsed success, except _id had value,other fields had empty value, and no exception for me, any mistake with me?

Steps to reproduce:
my demo code

private void Test(){
         var index = "test";
         var key = "Gid";
        var bulkJobjectList2 = new List<JObject>() {
                            new JObject() {
                                    { "Gid","1" },
                                    { "Title","test index bulk many 1 width JObject" }
                                },
                            new JObject() {
                                  { "Gid","2" },
                                  { "Title","test index bulk many 2 width JObject" }                          
                                }
                        };        
          EsHelper.ClientSet.IndexMany(index, key, bulkJobjectList2);
    } 

EsHelper  class IndexMany method :

public static IBulkResponse IndexMany(this IElasticClient client, string index, string keyField, IEnumerable<JObject> res) {
            var response = client.Bulk(b =>
                                        b.Index(index)
                                        .Type(index)
                                        .IndexMany(res, (f, o) =>  
                                            f.Document(o)
                                            .Id(o[keyField].Value<string>())
                                            )
                                       );
            return response;
        } 

Expected behavior
data save success,but only _id had vlaue,others were empty.

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):
`
Valid NEST response built from a successful low level call on POST: /test/test/_bulk?pretty=true&error_trace=true

Audit trail of this API call:

Request:

{"index":{"_id":"1"}}
{"Gid":[],"Title":[]}
{"index":{"_id":"2"}}
{"Gid":[],"Title":[]}

Response:

{
"took" : 6,
"errors" : false,
"items" : [
{
"index" : {
"_index" : "test",
"_type" : "test",
"_id" : "1",
"_version" : 3,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 7,
"_primary_term" : 1,
"status" : 200
}
},
{
"index" : {
"_index" : "test",
"_type" : "test",
"_id" : "2",
"_version" : 3,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 19,
"_primary_term" : 1,
"status" : 200
}
}
]
}
`

Tasks

No tasks being tracked yet.
@flobernd
Copy link
Member

Hi!

NEST 6.5.1 is a very old version and out of support..

How did you confirm your data was not written correctly? The bulk response does not return the full documents which means it's totally expected to only see _id and a few other meta fields.

The request looks good, so I assume your data is correctly written. You should try to request it in a second operation or manually check it in Kibana.

@wjfang90
Copy link
Author

wjfang90 commented Apr 1, 2024

Thank your reply,I known where was my wrong,Nest 6+ changed Json Serializer,stackoverflow had question,https://stackoverflow.com/questions/50107494/how-do-i-serialize-properties-of-type-jtoken-or-jobject-in-elasticsearch-nest

@wjfang90 wjfang90 closed this as completed Apr 1, 2024
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