【发布时间】:2022-01-19 16:07:19
【问题描述】:
我正在使用具有以下连接设置的 Nest:
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection());
settings.DisableDirectStreaming(true); // needed to see good looking debug log on insert
settings.DefaultIndex(Index);
Client = new ElasticClient(settings);
使用new InMemoryConnection() 我希望使用 Nest 进行查询 - 在 Azure 云函数中更改数据。
奇怪的是,调试日志看起来很有希望索引:
/*
var res = await Client.IndexManyAsync(response.Elements, Index); //
Console.WriteLine(res.DebugInformation);
*/
/*
var res = await Client.IndexAsync(response, i => i.Index(Index)); // Index = "data"
Console.WriteLine(res.DebugInformation); // <--
*/
并且在插入后直接记录计数为 0:
// var anyDocs = await Client.CountAsync<OverpassElement>(c => c.Index(Index));
var anyDocs = await Client.CountAsync<OverpassElement>(c => c);
Console.WriteLine("count: " + anyDocs.Count);
..但插入记录的整个 json 数据。
插入后怎么算不出来(以便下一步搜索)?
其实我明白了:
通过对 POST 的成功 (200) 低级别调用构建的无效 NEST 响应:/data/_doc
并且在IndexResponse插入中有0项。
数据属于Element,类似于包含 4221 个此类项目的数组的以下部分:
{
"type": "relation",
"id": 8353694,
"timestamp": "2018-06-04T22:54:27Z",
"version": 1,
"changeset": 59551528,
"user": "asdf2",
"uid": 1416503,
"members": [
{
"type": "way",
"ref": 89956942,
"role": "from"
},
{
"type": "node",
"ref": 1042756547,
"role": "via"
},
{
"type": "way",
"ref": 89956938,
"role": "to"
}
],
"tags": {
"restriction": "no_left_turn",
"type": "restriction"
}
},
【问题讨论】:
标签: nest