public ActionResult Index()
        {
            var client = EasySearchConfiguration.GetClient();

            var searchResults = client.Search <Person>(s => s
                                                       .From(0)
                                                       .Size(10)
                                                       .Query(q => q
                                                              .Term(p => p.Zip, "80301")
                                                              )
                                                       );

            var model = new SearchViewModel();

            model.Persons = searchResults.Documents;
            model.Total   = searchResults.Total;

            return(View(model));
        }
        private List <ElasticSearch.Models.Person> GetByZip(String zip)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            var client        = EasySearchConfiguration.GetClient();
            var searchResults = client.Search <PersonData>(s => s
                                                           .From(0)
                                                           .Size(10000)
                                                           .Query(q => q
                                                                  .Term(p => p.postCode, zip)
                                                                  )
                                                           );
            var search_result = searchResults.Documents.ToList();

            sw.Stop();
            result.Performance.ElapsedTime = Helper.ToReadbileTime(sw.ElapsedTicks);
            result.PostalCode = zip;

            return(Mapper.Map <List <PersonData>, List <Person> >(search_result));
        }
        public JsonResult SearchText(String SearchString)
        {
            //dynamic dyn = jsonData;
            //var searchString = dyn.SearchString.Value as string;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            var client        = EasySearchConfiguration.GetClient();
            var searchResults = client.Search <PersonData>(s => s
                                                           .AllTypes()
                                                           .From(0)
                                                           .Take(10000)
                                                           .Query(qry => qry
                                                                  .Bool(b => b
                                                                        .Must(m => m
                                                                              .QueryString(qs => qs
                                                                                           .DefaultField("_all")
                                                                                           .Query(String.Format("*{0}*", SearchString)))))));

            var search_result = searchResults.Documents.ToList <PersonData>();

            sw.Stop();
            result.Performance.ElapsedTime = Helper.ToReadbileTime(sw.ElapsedTicks);

            result.People = Mapper.Map <List <PersonData>, List <Person> >(search_result);

            if (result != null && result.People != null)
            {
                result.Count = result.People.Count;
                if (result.Count > 1000)
                {
                    result.People = null;
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
            //Request.CreateResponse(HttpStatusCode.OK, result);
        }