查询示例
编辑查询示例
编辑此页面演示如何执行搜索请求。
流式 API
编辑var response = await client .SearchAsync<Person>(search => search .Index("persons") .Query(query => query .Term(term => term .Field(x => x.FirstName) .Value("Florian") ) ) .Size(10) );
对象初始化器 API
编辑var response = await client .SearchAsync<Person>(new SearchRequest<Person>("persons") { Query = Query.Term(new TermQuery(Infer.Field<Person>(x => x.FirstName)) { Value = "Florian" }), Size = 10 });
使用响应
编辑foreach (var person in response.Documents) { Console.WriteLine(person.FirstName); }