Joseph Katzman
Joseph Katzman

Reputation: 2083

How to search data by using NEST API?

I have ElasticSearch client which has default settings.

elasticClient = new ElasticLowLevelClient();

Also I have a simple post entity.

[ElasticsearchType(IdProperty = "Id", Name = "post")]
    public class Post
    {
        [Number(Name = "id")]
        public int Id { get; set; }
        [Text(Name = "title")]
        public string Title { get; set; }
        [Text(Name = "description")]
        public string Description { get; set; }
    }

I want to execute the query which is similar to query from Es documentation:

var searchResults = client.Search<Post>(p=>p
    .From(0)
    .Size(10)
    .Query(q=>q
         .Term(p=>p.Title, "stackoverflow")
    )
);

But I think that ES API was changed. The first argument should be PostData. That's why I don't know how my query should look.

Version of my ElasticSearch is 2.3.5 Version of NEST is 5.0.1

Maybe I need a lower version of NEST?

Upvotes: 1

Views: 324

Answers (1)

Russ Cam
Russ Cam

Reputation: 125518

You're instantiating an instance of the low level client from Elasticsearch.Net.

If you change to using the high level client from NEST, all will be well

var elasticClient = new ElasticClient();

Internally, NEST uses the low level client, which is why Elasticsearch.Net is brought in as a dependency.

Upvotes: 1

Related Questions