Beispiel #1
0
 public static SearchSchema AddFields(this SearchSchema schema, IEnumerable <Field> fields)
 {
     foreach (var field in fields)
     {
         schema.Fields[field.Name] = field.ToSearchField();
     }
     return(schema);
 }
Beispiel #2
0
        public SearchClient(SearchConfig searchConfig, TelemetryClient telemetryClient)
        {
            _telemetryClient = telemetryClient;
            _searchConfig    = searchConfig;
            _searchClient    = new SearchServiceClient(searchConfig.ServiceName, new SearchCredentials(searchConfig.Key));

            Schema = new SearchSchema().AddFields(_searchClient.Indexes.Get(_searchConfig.IndexName).Fields);
            Model  = new SearchModel(Schema);
        }
Beispiel #3
0
        public SearchModel(SearchSchema schema)
        {
            Facets       = new List <SearchField>();
            Tags         = new List <SearchField>();
            SelectFilter = resultFields;

            if (facets.Count() > 0)
            {
                // add field to facets if in facets arr
                foreach (var field in facets)
                {
                    if (schema.Fields[field] != null && schema.Fields[field].IsFacetable)
                    {
                        Facets.Add(schema.Fields[field]);
                    }
                }
            }
            else
            {
                foreach (var field in schema.Fields.Where(f => f.Value.IsFacetable))
                {
                    Facets.Add(field.Value);
                }
            }

            if (tags.Count() > 0)
            {
                foreach (var field in tags)
                {
                    if (schema.Fields[field] != null && schema.Fields[field].IsFacetable)
                    {
                        Tags.Add(schema.Fields[field]);
                    }
                }
            }
            else
            {
                foreach (var field in schema.Fields.Where(f => f.Value.IsFacetable))
                {
                    Tags.Add(field.Value);
                }
            }
        }