public Dictionary<string, object> GetFields(Entity entity) { var fields = new Dictionary<string, object>(); foreach (Field field in entity.OutputFields()) { var alias = field.Alias.ToLower(); var type = _types.ContainsKey(field.SimpleType) ? _types[field.SimpleType] : field.SimpleType; if (type.Equals("string")) { foreach (var searchType in field.SearchTypes) { var analyzer = searchType.Analyzer.ToLower(); if (_analyzers.Contains(analyzer)) { if (fields.ContainsKey(alias)) { fields[alias + searchType.Name.ToLower()] = new Dictionary<string, object>() { { "type", type }, { "analyzer", analyzer } }; } else { if (analyzer.Equals(string.Empty)) { fields[alias] = new Dictionary<string, object>() { { "type", type } }; } else { fields[alias] = new Dictionary<string, object>() { { "type", type }, { "analyzer", analyzer } }; } } } else { _logger.EntityWarn(entity.Name, "Analyzer '{0}' specified in search type '{1}' is not supported. Please use a built-in analyzer for Solr.", analyzer, searchType.Name); if (!fields.ContainsKey(alias)) { fields[alias] = new Dictionary<string, object>() { { "type", type } }; } } } } else { fields[alias] = new Dictionary<string, object>() { { "type", type } }; } } if (!fields.ContainsKey("tflbatchid")) { fields.Add("tflbatchid", new Dictionary<string, object> { { "type", "long" } }); } if (!fields.ContainsKey("tfldeleted")) { fields.Add("tfldeleted", new Dictionary<string, object> { { "type", "boolean" } }); } return fields; }
public Dictionary<string, string> GetFieldMap(Entity entity) { var map = new Dictionary<string, string>(); foreach (Field field in entity.OutputFields()) { var alias = field.Alias.ToLower(); if (field.SimpleType.Equals("string")) { foreach (var searchType in field.SearchTypes) { if (map.ContainsKey(alias)) { map[alias + searchType.Name.ToLower()] = alias; } else { map[alias] = alias; } } } else { map[alias] = alias; } } if (!map.ContainsKey("tflbatchid")) { map.Add("tflbatchid", "tflbatchid"); } if (!map.ContainsKey("tfldeleted")) { map.Add("tfldeleted", "tfldeleted"); } return map; }