0

My question is simple. I can write a very awesome queries in postman ;

POST : localhost:9200/logstash-2017.08.28/_search?pretty=true

{
	"query":{
		"match":{
			
			"level":"Error"
		}
	}
	
}

But I have to this thing inside of C# code by using nest framework.But i can not do that can you help me?

   var response = EsClient().Search<DocumentAttributes>(s => s
                .Index("logstash-2017.09.18")
                .Type("json")
                .Query(q => q
                .Term(p => p.level, "Error")));

             //.Query(q => q.Raw(@"level:Error")));
             //      .Type("type").Query(q => q.Raw(@"{""match_all"":{}}")));

How can i write down by writing query or by using fields?

1 Answer 1

2

Your queries are not the same. For json query you specified the following path localhost:9200/logstash-2017.08.28/_search?pretty=true, which means you are going to search for all documents in index logstash-2017.08.28.

Lets see what you have in query written using NEST.

  1. Index method means that you are going to search for all documents in the given index
  2. Type method means that you are going to query all documents in given index which has the given type. In your case type is json. So Type method is for defining on which type of documents are you going to search.

So, the difference between your queries is that in first case you are querying all the documents in the index, but in second case you are querying all the documents in the index with type json.

Sign up to request clarification or add additional context in comments.

3 Comments

please don't focus on wrong part of question. you can use like that : localhost:9200/logstash-2017.08.28/json/_search
So your document name is json?
You are using match query in first query and term query in second query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.