// POST: api/Search
        public IHttpActionResult Post([FromBody] SearchQueryBody body)
        {
            string searchAddress = AppSettingsProvider.GetSetting(FieldNameUtil.GetMemberName((AzureSettingsNames c) => c.SearchServiceAddress));
            var    node          = new Uri(searchAddress);
            var    settings      = new ConnectionSettings(node);
            var    client        = new ElasticClient(settings);

            switch (body.ObjectType)
            {
            case ObjectType.TalentCandidate:

                SearchRequest <TalentCandidate> userRequest = null;
                userRequest = new SearchRequest <TalentCandidate>();

                userRequest.From = body.From;
                userRequest.Size = body.Size;
                if (!string.IsNullOrEmpty(body.FullText))
                {
                    userRequest.Query = new MatchQuery {
                        Field = "_all", Query = body.FullText, MinimumShouldMatch = body.MinimumShouldMatch
                    };
                }
                else
                {
                    //TODO implement this.
                }
                ISearchResponse <TalentCandidate> userResponse = client.Search <TalentCandidate>(userRequest);
                return(Json <IEnumerable <TalentCandidate> >(userResponse.Documents));

            default:
                return(null);
            }
        }
Example #2
0
 private void KeepWarm()
 {
     try
     {
         string baseUrl = AppSettingsProvider.GetSetting(FieldNameUtil.GetMemberName((AzureSettingsNames c) => c.ProductServiceAddress));
         RestApiCaller <string> warmersCaller = new RestApiCaller <string>(baseUrl);
         warmersCaller.Get("/odata/Warmers", false);
     }
     catch (Exception e)
     {
         Trace.TraceError(e.ToString());
     }
 }