Я новичок в Elastic Search, и моей задачей является тестирование нескольких функций в проекте .Net.
Функция использует эластичный запрос, и я попытался смоделировать его, используя подход InMemeory
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/modifying-default-connection.html#_using_inmemoryconnection
Ниже приведен ответ Json.
{
"took" : 76,
"timed_out" : false,
"hits" :
{
"total" : 1899,
"max_score" : 0,
},
"aggregations":
{
"jobs" :
{
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" :
{
"key" : "XYZ",
"doc_count" : 1800,
"runs" :
{
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" :
{
"key" : 49127,
"doc_count" : 3,
"groupby_runs" :
{
"hits" :
{
"total" : 3,
"max_score" : 0,
"hits" : []
{
{
"_type" : "testdocument" ,
"_index" : "test_docs-2018.10.08",
"_id" : "1-1-49127-37" ,
"_score" : 2,
"_source" :
{
"timeStamp" : "2018-10-08T08 :47 :18.781+05 :30" ,
"isPassed" : true,
"runSourceDuration : 6,
"runId" : 49127,
"runSourceName" : "XYZ" ,
"isReleaseValidation" : false
},
"sort" :1538968638781
},
{
"_type" : "test_docs-2018.10.08",
"_index" : "testdocument" ,
"_id" : "1-1-49127-39" ,
"_score" : 2,
"_source" :
{
"timeStamp " : "2018-10-08T08 :47 :18.781+05 :30" ,
"isPassed " : true,
"runSourceDuration " : 6,
"runId" : 49127,
"runSourceName" : "XYZ" ,
"isReleaseValidation" : false
},
"sort" :1538968638781
},
{
"_type" : "test_docs-2018.10.08",
"_index" "testdocument" ,
"_id" : "1-1-49127-47" ,
"_score" : 2,
"_source" :
{
"timeStamp " : "2018-10-08T08 :47 :18.781+05 :30" ,
"isPassed " : true,
"runSourceDuration " : 6,
"runId" : 49127,
"runSourceName" : "XYZ" ,
"isReleaseValidation" : false
},
"sort" :1538968638781
}
}
}
}
}
}
}
}
}
};
Я пытался преобразовать это в объект Anonymous Nest (C #). Но это не дает мне точный ожидаемый результат.
var response = new
{
took = 76,
timed_out = false,
hits = new
{
total = 1899,
max_score = 0,
},
aggregations = new
{
jobs = new
{
doc_count_error_upper_bound = 0,
sum_other_doc_count = 0,
Buckets = new
{
key = "XYZ",
doc_count = 1800,
runs = new
{
doc_count_error_upper_bound = 0,
sum_other_doc_count = 0,
Buckets = new
{
key = 49127,
doc_count = 3,
groupby_runs = new
{
hits = new
{
total = 3,
max_score = 0,
hits = new[]
{
new{
_index = "test_report_docs-2018.10.08",
_type = "testreportdocument" ,
_id = "1-1-49127-37" ,
_score = 2,
_source = new
{
timeStamp = "2018-10-08T08 =47 =18.781+05 =30" ,
isPassed = true,
runSourceDuration = 6,
runId = 49127,
runSourceName = "XYZ" ,
isReleaseValidation = false
},
sort =1538968638781
},
new{
_index = "test_docs-2018.10.08",
_type = "testdocument" ,
_id = "1-1-49127-39" ,
_score = 2,
_source = new
{
timeStamp = "2018-10-08T08 =47 =18.781+05 =30" ,
isPassed = true,
runSourceDuration = 6,
runId = 49127,
runSourceName = "XYZ" ,
isReleaseValidation = false
},
sort =1538968638781
},
new{
_index = "test_docs-2018.10.08",
_type = "testdocument" ,
_id = "1-1-49127-47" ,
_score = 2,
_source = new
{
timeStamp = "2018-10-08T08 =47 =18.781+05 =30" ,
isPassed = true,
runSourceDuration = 6,
runId = 491,
runSourceName = "XYZ" ,
isReleaseValidation = false
},
sort =1538968638781
}
}
}
}
}
}
}
}
}
};
var response = service.Search<TD>(new GetQuery().Query());
Я получаю
Bucket.count = 0 и
var jobs = response.Aggs.Terms ("jobs") возвращает ноль.
Не могли бы вы помочь мне исправить анонимный объект.