예제 #1
0
        public string SearchAll(FilterParam filterParam)
        {
            try
            {

                JObject query = new JObject();
                if (!string.IsNullOrEmpty(filterParam.SearchField)
                    && !string.IsNullOrEmpty(filterParam.SearchFieldValue))
                {
                    query["query"] = new JObject();
                    query["query"]["bool"] = new JObject();
                    query["query"]["bool"]["must"] = new JObject();
                    query["query"]["bool"]["must"]["query_string"] = new JObject();
                    query["query"]["bool"]["must"]["query_string"]["default_field"] = new JObject();
                    query["query"]["bool"]["must"]["query_string"]["default_field"] = filterParam.SearchField;
                    query["query"]["bool"]["must"]["query_string"]["query"] = new JObject();
                    query["query"]["bool"]["must"]["query_string"]["query"] = filterParam.SearchFieldValue;
                }

                query["sort"] = new JObject();
                query["sort"][filterParam.SortField] = new JObject();
                query["sort"][filterParam.SortField]["reverse"] = filterParam.Sort;
                query["from"] = filterParam.from;
                query["size"] = filterParam.size;
                string stringQuery = JsonConvert.SerializeObject(query);
                var ff = ElasticSearchManager.InstanceNet(filterParam.IpAddress).Search(string.IsNullOrEmpty(filterParam.IndexName) ? "_all" : filterParam.IndexName, stringQuery);
                return ff.Response["hits"];
            }
            catch (Exception)
            {
                return string.Empty;
            }

        }
예제 #2
0
 public string GetAllPropertiesv2(FilterParam filterParam)
 {
     var statusResponse = ElasticSearchManager.InstanceNet(filterParam.IpAddress).ClusterState();
     return statusResponse.Response["metadata"];
 }
예제 #3
0
 public string GetAllProperties(FilterParam filterParam)
 {
     var statusResponse = ElasticSearchManager.GetData(string.Format("{0}{1}", filterParam.IpAddress, "_stats"));
     return statusResponse;
 }
예제 #4
0
 public string GetNodes(FilterParam filterParam)
 {
     var statusResponse = ElasticSearchManager.InstanceNet(filterParam.IpAddress).ClusterState();
     return statusResponse.Response["nodes"];
 }