elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

Incorrect query in example documentation

Open borsna opened this issue 10 months ago • 0 comments

Elastic.Clients.Elasticsearch version:

Elasticsearch version: 8.x

.NET runtime version: 8

Operating system version:

Description of the problem including expected versus actual behavior: The provided example for a term query does not work for the new version. Have not tested the other examples so more examples have to be updated.

Steps to reproduce: Go to https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/examples.html#searching-net Example:

var response = await client.SearchAsync<Tweet>(s => s 
    .Index("my-tweet-index") 
    .From(0)
    .Size(10)
    .Query(q => q
        .Term(t => t.User, "stevejgordon") 
    )
);

if (response.IsValidResponse)
{
    var tweet = response.Documents.FirstOrDefault(); 
}

Expected behavior

The example should be:

var response = await client.SearchAsync<Tweet>(s => s 
    .Index("my-tweet-index") 
    .From(0)
    .Size(10)
    .Query(q => q
        .Term(t => t.Field(f => f.User).Value("stevejgordon")) 
    )
);

if (response.IsValidResponse)
{
    var tweet = response.Documents.FirstOrDefault(); 
}

borsna avatar Apr 12 '24 07:04 borsna