public virtual bool UpdateDocument(IDocument document, Category item, object context) { var indexStoreNotAnalyzed = new[] { IndexStore.Yes, IndexType.NotAnalyzed }; var indexStoreNotAnalyzedStringCollection = new[] { IndexStore.Yes, IndexType.NotAnalyzed, IndexDataType.StringCollection }; var indexStoreAnalyzedStringCollection = new[] { IndexStore.Yes, IndexType.Analyzed, IndexDataType.StringCollection }; document.Add(new DocumentField("__key", item.Id.ToLowerInvariant(), indexStoreNotAnalyzed)); document.Add(new DocumentField("__type", item.GetType().Name, indexStoreNotAnalyzed)); document.Add(new DocumentField("__sort", item.Name, indexStoreNotAnalyzed)); IndexIsProperty(document, "category"); var statusField = (item.IsActive != true || item.Id != null) ? "hidden" : "visible"; IndexIsProperty(document, statusField); document.Add(new DocumentField("status", statusField, indexStoreNotAnalyzed)); document.Add(new DocumentField("code", item.Code, indexStoreNotAnalyzed)); IndexIsProperty(document, item.Code); document.Add(new DocumentField("name", item.Name, indexStoreNotAnalyzed)); document.Add(new DocumentField("createddate", item.CreatedDate, indexStoreNotAnalyzed)); document.Add(new DocumentField("lastmodifieddate", item.ModifiedDate ?? DateTime.MaxValue, indexStoreNotAnalyzed)); document.Add(new DocumentField("priority", item.Priority, indexStoreNotAnalyzed)); document.Add(new DocumentField("lastindexdate", DateTime.UtcNow, indexStoreNotAnalyzed)); // Add priority in virtual categories to search index foreach (var link in item.Links) { document.Add(new DocumentField(string.Format(CultureInfo.InvariantCulture, "priority_{0}_{1}", link.CatalogId, link.CategoryId), link.Priority, indexStoreNotAnalyzed)); } // Add catalogs to search index var catalogs = item.Outlines .Select(o => o.Items.First().Id) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); foreach (var catalogId in catalogs) { document.Add(new DocumentField("catalog", catalogId.ToLowerInvariant(), indexStoreNotAnalyzedStringCollection)); } // Add outlines to search index var outlineStrings = GetOutlineStrings(item.Outlines); foreach (var outline in outlineStrings) { document.Add(new DocumentField("__outline", outline.ToLowerInvariant(), indexStoreNotAnalyzedStringCollection)); } // Index custom properties IndexItemCustomProperties(document, item); // add to content document.Add(new DocumentField("__content", item.Name, indexStoreAnalyzedStringCollection)); document.Add(new DocumentField("__content", item.Code, indexStoreAnalyzedStringCollection)); if (_settingsManager.GetValue("VirtoCommerce.SearchApi.UseFullObjectIndexStoring", true)) { var itemDto = item.ToWebModel(_blobUrlResolver); document.AddObjectFieldValue(itemDto); } return(true); }