public Dictionary<SystemEntity, Document> GenerateDocuments(IEnumerable<SystemEntity> entities) { Dictionary<Type, HashSet<SystemEntity>> dictionary = entities.GroupBy(entity => entity.GetType()) .ToDictionary(grouping => grouping.Key, grouping => grouping.ToHashSet()); Dictionary<SystemEntity, Document> documents = new Dictionary<SystemEntity, Document>(); foreach (Type key in dictionary.Keys) { Dictionary<int, UniversalSearchItem> items; if (!GetUniversalSearchItemTypes.ContainsKey(key)) items = new Dictionary<int, UniversalSearchItem>(); else { GetUniversalSearchItemBase getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[key]) as GetUniversalSearchItemBase; if (getUniversalSearchItem == null) items = new Dictionary<int, UniversalSearchItem>(); else items = getUniversalSearchItem.GetSearchItems(dictionary[key]) .ToDictionary(searchItem => searchItem.Id, searchItem => searchItem); } foreach (SystemEntity entity in dictionary[key]) { UniversalSearchItem item = items.ContainsKey(entity.Id) ? items[entity.Id] : null; documents.Add(entity, item == null ? null : _searchConverter.Convert(item)); } } return documents; }
public Document GenerateDocument(SystemEntity entity) { UniversalSearchItem item = GenerateItem(entity); if (item == null) return null; return _searchConverter.Convert(item); }
public Document Convert(UniversalSearchItem item) { Document document = new Document(); document.Add(new Field(UniversalSearchFieldNames.Id, item.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); string searchGuid = (item.SearchGuid).ToString(); document.Add(new Field(UniversalSearchFieldNames.SearchGuid, searchGuid, Field.Store.YES, Field.Index.NOT_ANALYZED)); string systemType = item.SystemType ?? string.Empty; document.Add(new Field(UniversalSearchFieldNames.SystemType, systemType, Field.Store.YES, Field.Index.NOT_ANALYZED)); //Tony touched here if (_entityTypes.ContainsKey(systemType)) { foreach (string entityType in _entityTypes[systemType]) { document.Add(new Field(UniversalSearchFieldNames.EntityType, entityType, Field.Store.NO, Field.Index.NOT_ANALYZED)); } } document.Add(new Field(UniversalSearchFieldNames.DisplayName, item.DisplayName, Field.Store.YES, Field.Index.NOT_ANALYZED) { Boost = 5 }); document.Add(new Field(UniversalSearchFieldNames.ActionUrl, item.ActionUrl ?? string.Empty, Field.Store.YES, Field.Index.NOT_ANALYZED)); document.Add(new Field(UniversalSearchFieldNames.CreatedOn, DateTools.DateToString(item.CreatedOn, DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.NOT_ANALYZED)); foreach (string searchTerm in (item.PrimarySearchTerms ?? Enumerable.Empty <string>()).Where(s => !string.IsNullOrWhiteSpace(s))) { document.Add(new Field(UniversalSearchFieldNames.PrimarySearchTerms, searchTerm, Field.Store.NO, Field.Index.ANALYZED) { Boost = 2 }); } foreach (string searchTerm in (item.SecondarySearchTerms ?? Enumerable.Empty <string>()).Where(s => !string.IsNullOrWhiteSpace(s))) { document.Add(new Field(UniversalSearchFieldNames.SecondarySearchTerms, searchTerm, Field.Store.NO, Field.Index.ANALYZED) { Boost = 0.8f }); } return(document); }
public UniversalSearchItem Convert(Document document) { var item = new UniversalSearchItem { Id = document.GetValue <int>(UniversalSearchFieldNames.Id), DisplayName = document.GetValue <string>(UniversalSearchFieldNames.DisplayName), SearchGuid = document.GetValue <Guid>(UniversalSearchFieldNames.SearchGuid), SystemType = document.GetValue <string>(UniversalSearchFieldNames.SystemType), ActionUrl = document.GetValue <string>(UniversalSearchFieldNames.ActionUrl), }; return(item); }
public UniversalSearchItemQuickSearch(UniversalSearchItem item) { _item = item; }
public AdminSearchResult(UniversalSearchItem item, SystemEntity entity) { _item = item; _entity = entity; }