public static SearchPrepareSettings ToSearchPrepareSettingsModel(this SearchSettingsWrapperElastic searchWrapper) { var model = new SearchPrepareSettings { DataSetName = searchWrapper.DataSetName }; return(model); }
public static SearchActivateSettings ToSearchActivateSettingsModel(this SearchSettingsWrapperElastic searchWrapper) { var model = new SearchActivateSettings { AutoCompleteSettings = searchWrapper.AutoCompleteSettings?.ToAutoCompleteSettingsModel(), ClassifierSettings = searchWrapper.ClassifierSettings?.ToClassifierSettingsModel(), SearchSettings = searchWrapper.SearchSettings?.ToSearchSettingsModel() }; return(model); }
private SearchSettingsWrapperElastic MergeSettings( SearchSettingsWrapperElastic defaultSettings, AutoCompleteSettings autoCompleteSettings, ClassifierSettings classifierSettings, SearchSettings searchSettings) { var result = new SearchSettingsWrapperElastic(defaultSettings); if (autoCompleteSettings != null) { result.AutoCompleteSettings = defaultSettings.AutoCompleteSettings != null?autoCompleteSettings.ToAutoCompleteSettingsElastic(defaultSettings.AutoCompleteSettings) : null; } if (classifierSettings != null) { result.ClassifierSettings = defaultSettings.ClassifierSettings != null?classifierSettings.ToClassifierSearchSettingsElastic(defaultSettings.ClassifierSettings) : null; } if (searchSettings != null) { result.SearchSettings = defaultSettings.SearchSettings != null?searchSettings.ToSearchSettingsElastic(defaultSettings.SearchSettings, true) : null; } return(result); }
public IActionResult Prepare(string id, [FromBody] SearchPrepareSettings searchPrepareSettings) { //SERVICE VALIDATION var service = serviceQuery.Get(id); if (service == null) { return(new HttpStatusCodeWithErrorResult(StatusCodes.Status404NotFound, ServiceResources.InvalidIdNotExistingService)); } if (service.Type != (int)ServiceTypeEnum.Search) { return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, string.Format(ServiceResources.InvalidServiceTypeOnly_0_ServicesAreValidForThisRequest, "Search"))); } if (service.Status != (int)ServiceStatusEnum.New) { return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, ServiceResources.InvalidStatusOnlyTheServicesWithNewStatusCanBePrepared)); } //DATASET VALIDATION if (!GlobalStore.DataSets.IsExist(searchPrepareSettings.DataSetName)) { return(new HttpStatusCodeWithErrorResult(StatusCodes.Status400BadRequest, string.Format(ServiceResources.DataSet_0_NotFound, searchPrepareSettings.DataSetName))); } var globalStoreDataSet = GlobalStore.DataSets.Get(searchPrepareSettings.DataSetName); var dataSet = globalStoreDataSet.DataSet; var serviceSettings = new SearchSettingsWrapperElastic { DataSetName = globalStoreDataSet.DataSet.Name, ServiceId = service.Id }; // SETUP default values for Activation - here we can calculate more accurate settings for the dataset var defaultActivationSettings = new SearchActivateSettings(); serviceSettings.AutoCompleteSettings = new AutoCompleteSettingsElastic { Confidence = 2.0, Count = 3, MaximumErrors = 0.5 }; serviceSettings.SearchSettings = new SearchSettingsElastic { Count = 3, CutOffFrequency = 0.001, Filter = null, Fuzziness = -1, ResponseFieldList = dataSet.InterpretedFields.Union(new List <string> { dataSet.IdField, dataSet.TagField }).ToList(), SearchFieldList = dataSet.InterpretedFields, Type = (int)SearchTypeEnum.Match, Weights = null, Operator = (int)LogicalOperatorEnum.OR, UseDefaultFilter = true, UseDefaultWeights = true, Order = null }; serviceQuery.IndexSettings(serviceSettings); var process = processHandler.Create( ProcessTypeEnum.SearchPrepare, service.Id, searchPrepareSettings, string.Format(ServiceResources.Preparing_0_Service_1, ServiceTypeEnum.Search, service.Name)); service.ProcessIdList.Add(process.Id); serviceQuery.Update(service.Id, service); processHandler.Start(process, (tokenSource) => searchHandler.Prepare(process.Id, serviceSettings, tokenSource.Token)); return(new HttpStatusCodeWithObjectResult(StatusCodes.Status202Accepted, process.ToProcessModel())); }