Exemple #1
0
        private Site GetSite(UniversalSearchIndexData indexData)
        {
            Models.UniversalSearchItem item = indexData.UniversalSearchItem;
            SiteEntity entity = _session.Get(item.SystemType, item.Id) as SiteEntity;

            return(entity == null || entity.Site == null
                ? _session.Get <Site>(_site.Id)
                : _session.Get <Site>(entity.Site.Id));
        }
Exemple #2
0
        public Document Convert(UniversalSearchItem item)
        {
            var 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));

            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 UniversalSearchItemQuickSearch(UniversalSearchItem item)
 {
     _item = item;
 }
Exemple #4
0
 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;
 }
Exemple #5
0
 public AdminSearchResult(UniversalSearchItem item, SystemEntity entity)
 {
     _item = item;
     _entity = entity;
 }