0
我正在玩弹性搜索,并在dotnet中进行了以下控制器操作。无法获得前缀查询,以使用弹性搜索dotnet
但前缀查询不起作用。
[Entities(Name = "ListStreams")]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
[ProducesResponseType(typeof(StreamEntity[]), (int)HttpStatusCode.OK)]
public async Task<IActionResult> ListStreams(
[FromResourceProvider] ResourceProviderRouteData route)
{
var clientFactory = new ElasticServiceClientFacotry();
var client = await clientFactory.CreateClientAsync();
var documentSearchResult = await client.SearchAsync<StreamEntity>(
k => k.Index("streams")
.Routing(route.Routing)
.Query(q=>q.Prefix(c=> c.Field("id").Value(route.ResourceId)))
,
HttpContext.RequestAborted);
return Ok(documentSearchResult.Documents);
}
下面的数据项是在索引
[
{
"name": "swl2x33p_vjv",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/EarthML.Streams/streams/swl2x33p_vjv",
"location": null,
"type": "EarthML.Streams/streams"
},
{
"name": "gkljqg2j_ic0",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/EarthML.Streams/streams/gkljqg2j_ic0",
"location": null,
"type": "EarthML.Streams/streams"
}
]
和route.ResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/EarthML.Streams"