Exemple #1
0
        public ActionResult RunQuery(RunQueryParameters parameters)
        {
            const string indexName = "testindex";

            string opResult = string.Empty;

            opResult = ElasticSearch.DeleteIndex(indexName);
            opResult = ElasticSearch.CreateIndex(indexName);
            opResult = ElasticSearch.CreateMapping(indexName, "test", parameters.Mapping);
            opResult = ElasticSearch.InsertDocument(indexName, "test", parameters.Documents, true);

            Thread.Sleep(2000);

            var response = ElasticSearch.RunSearch(indexName, "test", parameters.Query);

            return(Content(JsonSerialization.Serialize(new {
                queryResult = response
            })));
        }