public T Update(ISearchableContent contentItem)
 {
     return(Update(new ContentCrawlProxy()
     {
         ContentItem = contentItem
     }));
 }
Exemplo n.º 2
0
        private Document BuildDocumentFromContentItem(IContentItem contentItem, ITextExtractor textExtractor)
        {
            ISearchableContent searchInfo = contentItem as ISearchableContent;

            if (searchInfo == null)
            {
                throw new ArgumentException("Argument must implement ISearchableContent");
            }

            // Get the text of the content item to index
            string contentToIndex = searchInfo.ToSearchContent(textExtractor);
            // strip (x)html tags
            string plainTextContent = System.Text.RegularExpressions.Regex.Replace(contentToIndex, @"<(.|\n)*?>", string.Empty);
            // create the actual url
            string path = contentItem.GetContentUrl();
            // check that summary is not null.
            string summary = contentItem.Summary ?? Text.TruncateText(plainTextContent, 200);

            Document doc = new Document();

            doc.Add(new Field("globalid", contentItem.GlobalId.ToString("N"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("title", contentItem.Title, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("summary", summary, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("contents", plainTextContent, Field.Store.NO, Field.Index.TOKENIZED));
            doc.Add(new Field("author", contentItem.CreatedBy.FullName, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("moduletype", contentItem.Section.ModuleType.Name, Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("path", path, Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("site", contentItem.Section.Node.Site.Id.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("datecreated", contentItem.CreatedAt.ToString("u"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("datemodified", contentItem.ModifiedAt.ToString("u"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            if (contentItem.PublishedAt.HasValue)
            {
                doc.Add(new Field("datepublished", contentItem.PublishedAt.Value.ToString("u"), Field.Store.YES,
                                  Field.Index.UN_TOKENIZED));
            }
            // do not index the sectionid here (since it's used for access filtering)
            doc.Add(new Field("sectionid", contentItem.Section.Id.ToString(), Field.Store.YES, Field.Index.NO));

            foreach (Category cat in contentItem.Categories)
            {
                doc.Add(new Field("category", cat.Name, Field.Store.YES, Field.Index.UN_TOKENIZED));
            }

            foreach (Role viewRole in contentItem.ViewRoles)
            {
                doc.Add(new Field("viewroleid", viewRole.Id.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            }

            foreach (CustomSearchField field in searchInfo.GetCustomSearchFields())
            {
                Field.Store store = field.IsStored ? Field.Store.YES : Field.Store.NO;
                Field.Index index = field.IsTokenized ? Field.Index.TOKENIZED : Field.Index.UN_TOKENIZED;
                if (field.FieldKey != null && field.FieldValue != null)
                {
                    doc.Add(new Field(field.FieldKey, field.FieldValue, store, index));
                }
            }
            return(doc);
        }
Exemplo n.º 3
0
        public FindingsSequence(IContent article, IQuery query)
        {
            _article = new SearchableContent(article);
            _query   = query;
            _content = _article.Content.PlainText;

            Completion = new Progress(_content.Length);
        }
Exemplo n.º 4
0
 public SmartContextFinding(ISearchableContent article, int findingIndex, int findingLength) : base(findingIndex, findingLength)
 {
     _article       = article;
     _findingIndex  = findingIndex;
     _findingLength = findingLength;
 }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="asset"></param>
 /// <returns></returns>
 private T IndexerCallback(T doc, ISearchableContent asset)
 {
     return(doc);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="contentItem"></param>
 /// <returns></returns>
 public void Delete(ISearchableContent contentItem)
 {
     SearchClient.DeleteById(contentItem._ContentID);
 }