コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="umbracoHelper"></param>
        /// <param name="indexerName"></param>
        private void Indexer_DocumentWriting(object sender, DocumentWritingEventArgs e, UmbracoHelper umbracoHelper, string indexerName)
        {
            IPublishedContent publishedContent = null;

            publishedContent = umbracoHelper.TypedContent(e.NodeId);

            if (publishedContent == null)
            {
                // attempt to get as media
                publishedContent = umbracoHelper.TypedMedia(e.NodeId);

                if (publishedContent == null)
                {
                    // attempt to get as member
                    publishedContent = umbracoHelper.SafeTypedMember(e.NodeId);
                }
            }

            if (publishedContent != null)
            {
                this.EnsureUmbracoContext();

                var indexingContext = new IndexingContext(null, publishedContent, indexerName);

                LookService.Index(indexingContext, e.Document);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="indexerName">Name of the indexer for which this DocumentWriting event is being executed on</param>
        private static void DocumentWriting(object sender, DocumentWritingEventArgs e, string indexerName)
        {
            IPublishedContent publishedContent = null;

            if (LookService.Instance._umbracoHelper == null)
            {
                throw new Exception("Unexpected null value for UmbracoHelper - Look not initialized");
            }

            publishedContent = LookService.Instance._umbracoHelper.TypedContent(e.NodeId);

            if (publishedContent == null)
            {
                // attempt to get as media
                publishedContent = LookService.Instance._umbracoHelper.TypedMedia(e.NodeId);

                if (publishedContent == null)
                {
                    // attempt to get as member
                    publishedContent = LookService.Instance._umbracoHelper.SafeTypedMember(e.NodeId);
                }
            }

            if (publishedContent != null)
            {
                var indexingContext = new IndexingContext(
                    hostNode: null,
                    node: publishedContent,
                    indexerName: indexerName);

                LookService.EnsureContext();

                LookService.Index(indexingContext, e.Document);
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="indexerName">Name of the indexer for which this DocumentWriting event is being executed on</param>
        private static void DocumentWriting(object sender, DocumentWritingEventArgs e, string indexerName)
        {
            IPublishedContent publishedContent = null;

            var indexerConfiguration = LookService.GetIndexerConfiguration(indexerName);

            if (indexerConfiguration.ShouldIndexContent) // attempt to get content
            {
                publishedContent = LookService.Instance._umbracoHelper.TypedContent(e.NodeId);
            }

            if (publishedContent == null && indexerConfiguration.ShouldIndexMedia) // attempt to get as media
            {
                publishedContent = LookService.Instance._umbracoHelper.TypedMedia(e.NodeId);
            }

            if (publishedContent == null && indexerConfiguration.ShouldIndexMembers) // attempt to get as member
            {
                publishedContent = LookService.Instance._umbracoHelper.SafeTypedMember(e.NodeId);
            }

            if (publishedContent != null)
            {
                var indexingContext = new IndexingContext(null, publishedContent, indexerName);

                LookService.EnsureContext();

                LookService.Index(indexingContext, e.Document);
            }
        }
コード例 #4
0
        /// <summary>
        /// Handle custom Lucene indexing when the lucene document is writing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void ProjectIndexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            //if there is a "body" field, we'll strip the html but also store it's raw value
            if (e.Fields.ContainsKey("body"))
            {
                //store the raw value
                e.Document.Add(new Field(
                                   string.Concat(LuceneIndexer.SpecialFieldPrefix, "body"),
                                   e.Fields["body"],
                                   Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                //remove the current version field from the lucene doc
                e.Document.RemoveField("body");
                //add a 'body' field with stripped html
                e.Document.Add(new Field("body", e.Fields["body"].StripHtml(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
            }

            //If there is a versions field, we'll split it and index the same field on each version
            if (e.Fields.ContainsKey("versions"))
            {
                //split into separate versions
                var versions = e.Fields["versions"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                AddNumericalVersionValue(e, "num_versions", versions);

                //remove the current version field from the lucene doc
                e.Document.RemoveField("versions");

                foreach (var version in versions)
                {
                    //add a 'versions' field for each version (same field name but different values)
                    //not analyzed, we don't use this for searching
                    e.Document.Add(new Field("versions", version, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                }
            }

            //If there is a compatVersions field, we'll split it and index the same field on each version
            if (e.Fields.ContainsKey("compatVersions"))
            {
                //split into separate versions
                var compatVersions = e.Fields["compatVersions"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                AddNumericalVersionValue(e, "num_compatVersions", compatVersions);

                //remove the current compatVersions field from the lucene doc
                e.Document.RemoveField("compatVersions");

                foreach (var version in compatVersions)
                {
                    //add a 'compatVersions' field for each compatVersion (same field name but different values)
                    //not analyzed, we don't use this for searching
                    e.Document.Add(new Field("compatVersions", version, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                }
            }
        }
コード例 #5
0
ファイル: ExamineEvents.cs プロジェクト: nozebra/Umbraco-CMS
 private static void IndexerDocumentWriting(object sender, DocumentWritingEventArgs e)
 {
     if (e.Fields.Keys.Contains("nodeName"))
     {
         //add the lower cased version
         e.Document.Add(new Field("__nodeName",
                                  e.Fields["nodeName"].ToLower(),
                                  Field.Store.YES,
                                  Field.Index.ANALYZED,
                                  Field.TermVector.NO
                                  ));
     }
 }
コード例 #6
0
        /// <summary>
        /// Handle custom Lucene indexing when the lucene document is writing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void ProjectIndexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            //if there is a "body" field, we'll strip the html but also store it's raw value
            if (e.Fields.ContainsKey("body"))
            {
                //store the raw value
                e.Document.Add(new Field(
                                   string.Concat(LuceneIndexer.SpecialFieldPrefix, "body"),
                                   e.Fields["body"],
                                   Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                //remove the current version field from the lucene doc
                e.Document.RemoveField("body");
                //add a 'body' field with stripped html
                e.Document.Add(new Field("body", e.Fields["body"].StripHtml(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
            }

            var allVersions = new HashSet <string>();

            //each of these contains versions, we want to parse them all into one list and then ensure each of these
            //fields are not analyzed (just stored since we dont use them for searching)
            var delimitedVersionFields = new[] { "versions", "minimumVersionStrict", "compatVersions" };

            foreach (var fieldName in delimitedVersionFields)
            {
                //If there is a versions field, we'll split it and index the same field on each version
                if (e.Fields.ContainsKey(fieldName))
                {
                    //split into separate versions
                    var versions = e.Fields[fieldName].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var version in versions)
                    {
                        allVersions.Add(version);
                    }

                    //remove the current version field from the lucene doc
                    e.Document.RemoveField(fieldName);

                    foreach (var version in versions)
                    {
                        //add a 'versions' field for each version (same field name but different values)
                        //not analyzed, we don't use this for searching
                        e.Document.Add(new Field(fieldName, version, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                    }
                }
            }

            //now add all versions to a numerical field
            AddNumericalVersionValue(e, "num_version", allVersions.ToArray());
        }
コード例 #7
0
        /// <summary>
        /// Event handler to create a lower cased version of the node name, this is so we can support case-insensitive searching and still
        /// use the Whitespace Analyzer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private static void IndexerDocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            if (e.Fields.Keys.Contains("nodeName"))
            {
                //TODO: This logic should really be put into the content indexer instead of hidden here!!

                //add the lower cased version
                e.Document.Add(new Field("__nodeName",
                                         e.Fields["nodeName"].ToLower(),
                                         Field.Store.YES,
                                         Field.Index.ANALYZED,
                                         Field.TermVector.NO
                                         ));
            }
        }
コード例 #8
0
 private void Indexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
 {
     //if it is a 'news article' doc type then > BOOST it DOWN - the older the article, the lower the boost value
     if (e.Fields.ContainsKey("nodeTypeAlias") && e.Fields["nodeTypeAlias"] == "newsArticle")
     {
         float        boostValue   = 1f;
         const string umbDateField = "updateDate";
         if (e.Fields.ContainsKey(umbDateField))
         {
             DateTime updateDate    = DateTime.Parse(e.Fields[umbDateField]);
             var      daysInBetween = Math.Ceiling((DateTime.Now - updateDate).TotalDays + 1);            // +1 to avoid 0 days
             boostValue = (float)(1 / daysInBetween);
         }
         e.Document.SetBoost(boostValue);
     }
 }
コード例 #9
0
        /// <summary>
        /// This ensures that the special __Raw_ fields are indexed
        /// </summary>
        /// <param name="docArgs"></param>

        protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
        {
            var d = docArgs.Document;

            foreach (var f in docArgs.Fields.Where(x => x.Key.StartsWith(RawFieldPrefix)))
            {
                d.Add(new Field(
                          f.Key,
                          f.Value,
                          Field.Store.YES,
                          Field.Index.NO, //don't index this field, we never want to search by it
                          Field.TermVector.NO));
            }

            base.OnDocumentWriting(docArgs);
        }
コード例 #10
0
        /// <summary>
        /// This ensures that the special __Raw_ fields are indexed correctly
        /// </summary>
        /// <param name="docArgs"></param>
        protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
        {
            var d = docArgs.Document;

            foreach (var f in docArgs.ValueSet.Values.Where(x => x.Key.StartsWith(UmbracoExamineFieldNames.RawFieldPrefix)).ToList())
            {
                if (f.Value.Count > 0)
                {
                    //remove the original value so we can store it the correct way
                    d.RemoveField(f.Key);

                    d.Add(new StoredField(f.Key, f.Value[0].ToString()));
                }
            }

            base.OnDocumentWriting(docArgs);
        }
コード例 #11
0
        //ex. 4, 5-6
        //BOOSTING set and SORTING on system and custom fields for frontend indexed text-content (external indexes)
        private void Indexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            //ex. 4
            //if it is a 'news item' doc type AND the news has a tag 'featured' then > BOOST it up - else set to 1
            if (e.Fields.ContainsKey("nodeTypeAlias") && e.Fields["nodeTypeAlias"] == "umbNewsItem")
            {
                if (e.Fields.ContainsKey("newsTag") && e.Fields["newsTag"] == "featured")
                {
                    e.Document.SetBoost(1000f);
                }
                else
                {
                    e.Document.SetBoost(1.0f);
                }
            }

            //from ex. 5 to ex. 6 - sorting search-results by custom field configuration -
            const string customDateField = "reviewDate";        //alias added field to Master doc. Type

            DateTime reviewDate = new DateTime();

            if (e.Fields.ContainsKey(customDateField))
            {
                reviewDate = DateTime.Parse(e.Fields[customDateField]);
            }
            else
            {
                //in case the review date is not set/available in the content, use system field date for updated content 'updateDate'
                reviewDate = DateTime.Parse(e.Fields["updateDate"]);
            }

            //1 CREATION OF the field that is not tokenizable because not analyzed but used as sortable because the '_' that tells Lucene it is sortabl
            //LuceneIndexer.SortedFieldNamePrefix = __Sort_
            //var field = new Field("___Sort_" + customDateField,  ...
            //in __Sort_reviewDate the '__' implies is not analysed therefore can be used for sorting

            var field = new Field(LuceneIndexer.SortedFieldNamePrefix + customDateField,
                                  reviewDate.ToString("yyyyMMddHHmmss", CultureInfo.InstalledUICulture),
                                  Field.Store.YES, Field.Index.NOT_ANALYZED);

            //.not_analyzed why? Lucene will NOT create an index on that custom field 'review date'
            //but it will treat the field as ONE value (because not tokenized/analyzed)

            //2 ADD the created filed to the document
            e.Document.Add(field);
        }
コード例 #12
0
        /// <summary>
        /// Given the string versions, this will put them into the index as numerical versions, this way we can compare/range query, etc... on versions
        /// </summary>
        /// <param name="e"></param>
        /// <param name="fieldName"></param>
        /// <param name="versions"></param>
        /// <remarks>
        /// This stores a numerical version as a Right padded 3 digit combined long number. Example:
        /// 7.5.0 would be:
        ///     007005000 = 7005000
        /// 4.11.0 would be:
        ///     004011000 = 4011000
        /// </remarks>
        private static void AddNumericalVersionValue(DocumentWritingEventArgs e, string fieldName, IEnumerable <string> versions)
        {
            var numericalVersions = versions.Select(x =>
            {
                System.Version o;
                return(System.Version.TryParse(x, out o) ? o : null);
            })
                                    .Where(x => x != null)
                                    .Select(x => x.GetNumericalValue())
                                    .ToArray();

            foreach (var numericalVersion in numericalVersions)
            {
                //don't store, we're just using this to search
                var versionField = new NumericField(fieldName, Field.Store.YES, true).SetLongValue(numericalVersion);
                e.Document.Add(versionField);
            }
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="indexerName">Name of the indexer for which this DocumentWriting event is being executed on</param>
        private static void DocumentWriting(object sender, DocumentWritingEventArgs e, string indexerName)
        {
            IPublishedContent publishedContent = null;

            if (LookService.Instance._umbracoHelper == null)
            {
                throw new Exception("Unexpected null value for UmbracoHelper - Look not initialized");
            }

            publishedContent = LookService.Instance._umbracoHelper.TypedContent(e.NodeId);

            if (publishedContent == null)
            {
                // attempt to get as media
                publishedContent = LookService.Instance._umbracoHelper.TypedMedia(e.NodeId);

                if (publishedContent == null)
                {
                    // attempt to get as member
                    publishedContent = LookService.Instance._umbracoHelper.SafeTypedMember(e.NodeId);
                }
            }

            if (publishedContent != null)
            {
                var dummyHttpContext = new HttpContextWrapper(new HttpContext(new SimpleWorkerRequest("", "", new StringWriter())));

                UmbracoContext.EnsureContext(
                    dummyHttpContext,
                    ApplicationContext.Current,
                    new WebSecurity(dummyHttpContext, ApplicationContext.Current),
                    UmbracoConfig.For.UmbracoSettings(),
                    UrlProviderResolver.Current.Providers,
                    true,
                    false);

                var indexingContext = new IndexingContext(
                    hostNode: null,
                    node: publishedContent,
                    indexerName: indexerName);

                LookService.Index(indexingContext, e.Document);
            }
        }
コード例 #14
0
ファイル: ExamineIndexer.cs プロジェクト: ziachap/LiveLink
        public static void EventIndexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            var document = e.Document;

            var id = int.Parse(e.Fields["id"]);

            var doubleFormatter = new DoubleIndexFormatter();
            var intFormatter    = new IntegerIndexFormatter();

            var evt   = new Node(id);
            var venue = evt.Parent;

            document.Add(new Field("venue", intFormatter.Format(venue.Id),
                                   Field.Store.YES, Field.Index.NOT_ANALYZED));

            var contentLongitude = venue.GetProperty("contentLongitude").Value;

            if (!string.IsNullOrEmpty(contentLongitude))
            {
                var contentLongitudeFormatted = doubleFormatter.Format(double.Parse(contentLongitude));
                document.Add(new Field("contentLongitude", contentLongitudeFormatted,
                                       Field.Store.YES, Field.Index.NOT_ANALYZED));
            }

            var contentLatitude = venue.GetProperty("contentLatitude").Value;

            if (!string.IsNullOrEmpty(contentLongitude))
            {
                var contentLatitudeFormatted = doubleFormatter.Format(double.Parse(contentLatitude));
                document.Add(new Field("contentLatitude", contentLatitudeFormatted,
                                       Field.Store.YES, Field.Index.NOT_ANALYZED));
            }

            var city = venue.Parent;

            document.Add(new Field("city", intFormatter.Format(city.Id),
                                   Field.Store.YES, Field.Index.NOT_ANALYZED));

            var country = city.Parent;

            document.Add(new Field("country", intFormatter.Format(country.Id),
                                   Field.Store.YES, Field.Index.NOT_ANALYZED));
        }
コード例 #15
0
        /// <summary>
        /// Handle custom Lucene indexing when the lucene document is writing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void ProjectIndexer_DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            //TODO: This will be good to do but we need the bleeding edge version of examine v1.x which i haven't released yet

            ////If there is a versions field, we'll split it and index the same field on each version
            //if (e.Fields.ContainsKey("versions"))
            //{
            //    //split into separate versions
            //    var versions = e.Fields["versions"].Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);

            //    //remove the current version field from the lucene doc
            //    e.Document.RemoveField("versions");

            //    foreach (var version in versions)
            //    {
            //        //add a 'versions' field for each version (same field name but different values)
            //        e.Document.Add(new Field("versions", version, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
            //    }
            //}
        }
コード例 #16
0
        /// <summary>
        /// This ensures that the special __Raw_ fields are indexed correctly
        /// </summary>
        /// <param name="docArgs"></param>
        protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
        {
            var d = docArgs.Document;

            foreach (var f in docArgs.ValueSet.Values.Where(x => x.Key.StartsWith(RawFieldPrefix)).ToList())
            {
                if (f.Value.Count > 0)
                {
                    //remove the original value so we can store it the correct way
                    d.RemoveField(f.Key);

                    d.Add(new Field(
                              f.Key,
                              f.Value[0].ToString(),
                              Field.Store.YES,
                              Field.Index.NO, //don't index this field, we never want to search by it
                              Field.TermVector.NO));
                }
            }

            base.OnDocumentWriting(docArgs);
        }
コード例 #17
0
        /// <summary>
        /// Used to create the additional search fields
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal static void DocumentWriting(object sender, DocumentWritingEventArgs e)
        {
            if (e.Fields.ContainsKey(LookService.DateField)) // it's storing a date value as a long type
            {
                if (long.TryParse(e.Fields[LookService.DateField], out long ticks))
                {
                    e.Document.RemoveFields(LookService.DateField);

                    var dateField = new NumericField(
                        LookService.DateField,
                        Field.Store.YES,
                        false)
                                    .SetLongValue(ticks);

                    var dateSortedField = new NumericField(
                        LuceneIndexer.SortedFieldNamePrefix + LookService.DateField,
                        Field.Store.NO,                     //we don't want to store the field because we're only using it to sort, not return data
                        true)
                                          .SetLongValue(ticks);

                    e.Document.Add(dateField);
                    e.Document.Add(dateSortedField);
                }
            }

            if (e.Fields.ContainsKey(LookService.NameField))
            {
                var name = e.Fields[LookService.NameField];

                e.Document.RemoveFields(LookService.NameField);

                var nameField = new Field(
                    LookService.NameField,
                    name,
                    Field.Store.YES,
                    Field.Index.NOT_ANALYZED,
                    Field.TermVector.YES);

                var nameSortedField = new Field(
                    LuceneIndexer.SortedFieldNamePrefix + LookService.NameField,
                    name.ToLower(),
                    Field.Store.NO,
                    Field.Index.NOT_ANALYZED,
                    Field.TermVector.NO);

                e.Document.Add(nameField);
                e.Document.Add(nameSortedField);
            }

            if (e.Fields.ContainsKey(LookService.LocationField))
            {
                var location = new Location(e.Fields[LookService.LocationField]);

                var locationLatitudeField = new Field(
                    LookService.LocationField + "_Latitude",
                    NumericUtils.DoubleToPrefixCoded(location.Latitude),
                    Field.Store.YES,
                    Field.Index.NOT_ANALYZED);

                var locationLongitudeField = new Field(
                    LookService.LocationField + "_Longitude",
                    NumericUtils.DoubleToPrefixCoded(location.Longitude),
                    Field.Store.YES,
                    Field.Index.NOT_ANALYZED);


                e.Document.Add(locationLatitudeField);
                e.Document.Add(locationLongitudeField);

                foreach (var cartesianTierPlotter in LookService.Instance.CartesianTierPlotters)
                {
                    var boxId = cartesianTierPlotter.GetTierBoxId(location.Latitude, location.Longitude);

                    var tierField = new Field(
                        cartesianTierPlotter.GetTierFieldName(),
                        NumericUtils.DoubleToPrefixCoded(boxId),
                        Field.Store.YES,
                        Field.Index.NOT_ANALYZED_NO_NORMS);

                    e.Document.Add(tierField);
                }
            }
        }
コード例 #18
0
        private void Indexer_DocumentWriting(BaseUmbracoIndexer indexer, DocumentWritingEventArgs e, string indexerName)
        {
            e.Fields.TryGetValue(Constants.PropertyAlias.NodeTypeAlias, out string documentAlias);
            var customizers = _IndexCustomizers
                              .Where(c => c.CanIndex(documentAlias ?? "", indexerName));

            foreach (var customizer in customizers)
            {
                var customizedProperties = customizer.CustomizeItems(e.Fields, indexer.DataService) ?? Enumerable.Empty <IContentIndexItem>();

                foreach (var customized in customizedProperties)
                {
                    if (string.IsNullOrWhiteSpace(customized.FieldName))
                    {
                        throw new NullReferenceException($"{customized.GetType().FullName} returned an empty value for {nameof(customized.FieldName)}!");
                    }

                    if (e.Fields.ContainsKey(customized.FieldName))
                    {
                        e.Document.RemoveField(customized.FieldName);
                    }

                    //"Examine.LuceneEngine.SearchCriteria.LuceneBooleanOperation" orderBy imple
                    //https://github.com/Shazwazza/Examine/blob/master/src/Examine/LuceneEngine/Providers/LuceneIndexer.cs#L1283

                    Field.Store      store         = customized.Store ? Field.Store.YES : Field.Store.NO;
                    Field.TermVector termVector    = customized.Store ? Field.TermVector.YES : Field.TermVector.NO;
                    Field.Index      analyzed      = customized.Analyzed ? Field.Index.ANALYZED : Field.Index.NOT_ANALYZED;
                    Field            field         = null;
                    Field            sortableField = null;
                    string           sortableValue = customized.Value;

                    if (customized.ValueType == typeof(string))
                    {
                        field = new Field(customized.FieldName, customized.Value, store, analyzed, termVector);
                    }
                    else if (customized.ValueType == typeof(DateTime))
                    {
                        DateTime custom = DateTime.Parse(customized.Value);
                        sortableValue = DateTools.DateToString(custom, DateTools.Resolution.MILLISECOND);
                        field         = new Field(customized.FieldName, sortableValue, Field.Store.YES, Field.Index.NOT_ANALYZED);
                    }
                    else
                    {
                        throw new ArgumentException($"{customized.FieldName} has type of {customized.ValueType.FullName} which isn't supported for index customizing!");
                    }

                    e.Document.Add(field);

                    if (customized.Sortable)
                    {
                        sortableField = sortableField ??
                                        new Field
                                        (
                            LuceneIndexer.SortedFieldNamePrefix + customized.FieldName,
                            sortableValue,
                            Field.Store.NO,
                            Field.Index.NOT_ANALYZED,
                            Field.TermVector.NO
                                        );

                        e.Document.Add(sortableField);
                    }
                }
            }
        }
コード例 #19
0
 protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
 {
     base.OnDocumentWriting(docArgs);
 }
コード例 #20
0
 private void BrowserIndexer_DocumentWriting(IEnumerable <IFacetField> facetFields, object sender, DocumentWritingEventArgs e)
 {
     foreach (var facetField in facetFields)
     {
         if (e.Fields.ContainsKey(facetField.Alias))
         {
             var facetValue = e.Fields[facetField.Alias];
             foreach (var value in facetField.PrepareForIndex(facetValue))
             {
                 e.Document.Add(facetField.CreateIndexField(value));
             }
         }
     }
 }
コード例 #21
0
 public void OnDocumentWriting(DocumentWritingEventArgs e)
 {
 }