# Query data from C# program the result not equal to the data filter from kibana

**URL:** <https://discuss.elastic.co/t/query-data-from-c-program-the-result-not-equal-to-the-data-filter-from-kibana/255428>\
**Category:** Elasticsearch\
**Created:** [November 15, 2020, 8:13am UTC](https://discuss.elastic.co/t/query-data-from-c-program-the-result-not-equal-to-the-data-filter-from-kibana/255428 "2020-11-15T08:13:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [November 15, 2020, 8:13am UTC](https://discuss.elastic.co/t/query-data-from-c-program-the-result-not-equal-to-the-data-filter-from-kibana/255428/1 "2020-11-15T08:13:51Z")

</div>

I am new to C#, and I want to write a program to query data from elasticsearch.  
First of all, I load kibana sample log and want to query from my C# program, and below is my C# program. I want to filter clientip is 20.102.50.96 logs.

```
class Program
    {
        static void Main(string[] args)
        {
            var settings = new ConnectionSettings(new Uri("http://127.0.0.1:9200"))
            .DefaultIndex("kibana_sample_data_logs");
            var client = new ElasticClient(settings);

            var searchResponse = client.Search<SampleLog>(s => s
            .From(0)
            .Size(10)
            .Query(q => q
                 .Match(m => m
                    .Field(f => f.clientip)
                    .Query("20.102.50.96")
                  )
                )
            );
            var logs = searchResponse.Documents;
            foreach(SampleLog p in logs)
            {
                Console.WriteLine(p.bytes);
                Console.WriteLine(p.url);
                Console.WriteLine(p.clientip);
                Console.WriteLine(p.message);

            }
            Console.WriteLine(logs.Count);
        }
    }

```

I am confused that if my log has 40 fields, and do I need initialize 40 var such as below?  
Does it affect the result data?

```
public class SampleLog
    {
        public string extension { get; set; }
        public string clientip { get; set; }
        public string message { get; set; }
        public string url { get; set; }
        public int bytes { get; set; }
    }

```

when I run my code, the result has 10 logs:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/c/3c87654233866d1d0139a757862c894ebf9a0421.png)  
However, I can't find so many logs from kibana, and there are only two logs:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81872926678cbd1975d4739c704fab36c635828f.png)  
thanks a lot !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2020, 8:14am UTC](https://discuss.elastic.co/t/query-data-from-c-program-the-result-not-equal-to-the-data-filter-from-kibana/255428/2 "2020-12-13T08:14:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
