コード例 #1
0
        public void RunIndexingOn(string uuid)
        {
            try
            {
                SetNorwegianIndexCores();
                RemoveIndexDocument(uuid);

                var article = _articleFether.FetchArticleDocumentAsync(uuid, Culture.NorwegianCode).Result;

                if (article != null)
                {
                    ArticleIndexDoc articleIndexDoc = _indexDocumentCreator.CreateIndexDoc(article);
                    RunIndex(articleIndexDoc);
                }

                SetEnglishIndexCores();
                RemoveIndexDocument(uuid);

                article = _articleFether.FetchArticleDocumentAsync(uuid, Culture.EnglishCode).Result;

                if (article != null)
                {
                    ArticleIndexDoc articleIndexDoc = _indexDocumentCreator.CreateIndexDoc(article);
                    RunIndex(articleIndexDoc);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error in UUID: " + uuid + "", exception);
                _errorService.AddError(uuid, exception);
            }
        }
コード例 #2
0
 public SearchResultItem(ArticleIndexDoc doc)
 {
     Uuid         = doc.Id;
     Type         = doc.Type;
     StartPublish = doc.StartPublish;
     Title        = doc.Heading;
     Intro        = doc.MainIntro;
     Body         = doc.MainBody;
     DetailsUrl   = doc.LinkUrl;
     Author       = doc.Author;
 }
        public ArticleIndexDoc CreateIndexDoc(Models.Article.ArticleDocument document)
        {
            var indexDoc = new ArticleIndexDoc();

            try
            {
                indexDoc.Id      = document.Id;
                indexDoc.Type    = document.Type;
                indexDoc.Heading = document.Heading;
                if (document.MainIntro != null)
                {
                    indexDoc.MainIntro = document.MainIntro.ToString();
                }
                if (document.MainBody != null)
                {
                    indexDoc.MainBody = document.MainBody.Substring(0, document.MainBody.Length > 30000 ? 30000 : document.MainBody.Length);
                }
                indexDoc.StartPublish = document.StartPublish;
                if (document.LinkUrl.StartsWith("/"))
                {
                    indexDoc.LinkUrl = WebConfigurationManager.AppSettings["GeonorgeUrl"] + document.LinkUrl.TrimStart('/');
                }
                else
                {
                    indexDoc.LinkUrl = document.LinkUrl;
                }
                //foreach (var linkArea in document.LinkArea)
                //{
                //    indexDoc.LinkArea.Add(linkArea.ToString());
                //}

                indexDoc.Author = document.Author;

                Log.Info(string.Format("Indexing metadata with uuid={0}, Heading={1}", indexDoc.Id,
                                       indexDoc.Heading));
            }
            catch (Exception e)
            {
                Log.Error("Exception while parsing article with Id: " + document.Id, e);
            }
            return(indexDoc);
        }
コード例 #4
0
 public void Index(ArticleIndexDoc doc)
 {
     Log.Info(string.Format("Indexing single document Id={0} Heading={1}", doc.Id, doc.Heading));
     _solr.Add(doc);
     _solr.Commit();
 }
コード例 #5
0
 private void RunIndex(ArticleIndexDoc articleIndexDoc)
 {
     _indexer.Index(articleIndexDoc);
 }