protected virtual void IndexOrganization(IndexDocument document, Organization organization) { document.AddSearchableValue(organization.Description); document.AddFilterableValue("BusinessCategory", organization.BusinessCategory); document.AddFilterableValue("OwnerId", organization.OwnerId); AddParentOrganizations(document, new[] { organization.ParentId }); }
protected virtual IndexDocument CreateDocument(Member member) { var document = new IndexDocument(member.Id); document.AddFilterableValue("MemberType", member.MemberType); document.AddFilterableAndSearchableValue("Name", member.Name); document.AddFilterableAndSearchableValues("Emails", member.Emails); document.AddFilterableAndSearchableValues("Phones", member.Phones); document.AddFilterableValues("Groups", member.Groups); document.AddFilterableValue("CreatedDate", member.CreatedDate); document.AddFilterableValue("ModifiedDate", member.ModifiedDate ?? member.CreatedDate); if (member.Addresses?.Any() == true) { foreach (var address in member.Addresses) { IndexAddress(document, address); } } if (member.Notes?.Any() == true) { foreach (var note in member.Notes) { IndexNote(document, note); } } var contact = member as Contact; var employee = member as Employee; var organization = member as Organization; var vendor = member as Vendor; if (contact != null) { IndexContact(document, contact); } else if (employee != null) { IndexEmployee(document, employee); } else if (organization != null) { IndexOrganization(document, organization); } else if (vendor != null) { IndexVendor(document, vendor); } if (!member.DynamicProperties.IsNullOrEmpty()) { foreach (var property in member.DynamicProperties) { IndexDynamicProperty(document, property); } } return(document); }
protected virtual void IndexEmployee(IndexDocument document, Employee employee) { document.AddFilterableAndSearchableValue("Salutation", employee.Salutation); document.AddFilterableAndSearchableValue("FullName", employee.FullName); document.AddFilterableAndSearchableValue("FirstName", employee.FirstName); document.AddFilterableAndSearchableValue("MiddleName", employee.MiddleName); document.AddFilterableAndSearchableValue("LastName", employee.LastName); document.AddFilterableValue("BirthDate", employee.BirthDate); AddParentOrganizations(document, employee.Organizations); document.AddFilterableValue("EmployeeType", employee.EmployeeType); document.AddFilterableValue("IsActive", employee.IsActive); }
protected virtual void IndexContact(IndexDocument document, Contact contact) { document.AddFilterableAndSearchableValue("Salutation", contact.Salutation); document.AddFilterableAndSearchableValue("FullName", contact.FullName); document.AddFilterableAndSearchableValue("FirstName", contact.FirstName); document.AddFilterableAndSearchableValue("MiddleName", contact.MiddleName); document.AddFilterableAndSearchableValue("LastName", contact.LastName); document.AddFilterableValue("BirthDate", contact.BirthDate); AddParentOrganizations(document, contact.Organizations); document.AddFilterableValue("TaxpayerId", contact.TaxPayerId); document.AddFilterableValue("PreferredDelivery", contact.PreferredDelivery); document.AddFilterableValue("PreferredCommunication", contact.PreferredCommunication); }
protected virtual void AddParentOrganizations(IndexDocument document, ICollection <string> values) { var nonEmptyValues = values?.Where(v => !string.IsNullOrEmpty(v)).ToArray(); document.AddFilterableValues("ParentOrganizations", nonEmptyValues); document.AddFilterableValue("HasParentOrganizations", nonEmptyValues?.Any() ?? false); }
protected virtual IndexDocument CreateDocument(VideoLink link) { var document = new IndexDocument(link.Id); document.AddFilterableValue("__sort", link.Url); var statusField = Enum.GetName(typeof(VideoLinkStatus), link.Status); IndexIsProperty(document, statusField); document.AddFilterableValue("status", statusField); document.AddFilterableValue("createddate", link.CreatedDate); document.AddFilterableValue("lastmodifieddate", link.ModifiedDate ?? DateTime.MaxValue); document.AddFilterableValue("modifieddate", link.ModifiedDate ?? DateTime.MaxValue); return(document); }
protected virtual void IndexVendor(IndexDocument document, Vendor vendor) { document.AddSearchableValue(vendor.Description); document.AddFilterableValue("GroupName", vendor.GroupName); }
protected virtual IndexDocument CreateDocument(CatalogProduct product) { var document = new IndexDocument(product.Id); document.AddFilterableValue("__type", product.GetType().Name); document.AddFilterableValue("__sort", product.Name); var statusField = product.IsActive != true || product.MainProductId != null ? "hidden" : "visible"; IndexIsProperty(document, statusField); IndexIsProperty(document, string.IsNullOrEmpty(product.MainProductId) ? "product" : "variation"); IndexIsProperty(document, product.Code); document.AddFilterableValue("status", statusField); document.AddFilterableAndSearchableValue("sku", product.Code); document.AddFilterableAndSearchableValue("code", product.Code);// { IsRetrievable = true, IsFilterable = true, IsCollection = true }); document.AddFilterableAndSearchableValue("name", product.Name); document.AddFilterableValue("startdate", product.StartDate); document.AddFilterableValue("enddate", product.EndDate ?? DateTime.MaxValue); document.AddFilterableValue("createddate", product.CreatedDate); document.AddFilterableValue("lastmodifieddate", product.ModifiedDate ?? DateTime.MaxValue); document.AddFilterableValue("modifieddate", product.ModifiedDate ?? DateTime.MaxValue); document.AddFilterableValue("priority", product.Priority); document.AddFilterableValue("vendor", product.Vendor ?? ""); document.AddFilterableValue("productType", product.ProductType ?? ""); document.AddFilterableValue("mainProductId", product.MainProductId ?? ""); // Add priority in virtual categories to search index if (product.Links != null) { foreach (var link in product.Links) { document.AddFilterableValue($"priority_{link.CatalogId}_{link.CategoryId}", link.Priority); } } // Add catalogs to search index var catalogs = product.Outlines .Select(o => o.Items.First().Id) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); document.AddFilterableValues("catalog", catalogs); // Add outlines to search index var outlineStrings = GetOutlineStrings(product.Outlines); document.AddFilterableValues("__outline", outlineStrings); document.AddFilterableValues("__outline_named", GetOutlineStrings(product.Outlines, getNameLatestItem: true)); // Add the all physical and virtual paths document.AddFilterableValues("__path", product.Outlines.Select(x => string.Join("/", x.Items.Take(x.Items.Count - 1).Select(i => i.Id))).ToList()); // Types of properties which values should be added to the searchable __content field var contentPropertyTypes = new[] { PropertyType.Product, PropertyType.Variation }; // Index custom product properties IndexCustomProperties(document, product.Properties, contentPropertyTypes); //Index product category properties if (product.Category != null) { IndexCustomProperties(document, product.Category.Properties, contentPropertyTypes); } //Index catalog properties if (product.Catalog != null) { IndexCustomProperties(document, product.Catalog.Properties, contentPropertyTypes); } if (StoreObjectsInIndex) { // Index serialized product document.AddObjectFieldValue(product); } return(document); }
protected virtual IndexDocument CreateDocument(CatalogProduct product) { var document = new IndexDocument(product.Id); document.AddFilterableValue("__type", product.GetType().Name); document.AddFilterableValue("__sort", product.Name); var statusField = product.IsActive != true || product.MainProductId != null ? "hidden" : "visible"; IndexIsProperty(document, statusField); IndexIsProperty(document, "product"); IndexIsProperty(document, product.Code); document.AddFilterableValue("status", statusField); document.AddFilterableAndSearchableValue("code", product.Code);// { IsRetrievable = true, IsFilterable = true, IsCollection = true }); document.AddFilterableAndSearchableValue("name", product.Name); document.AddFilterableValue("startdate", product.StartDate); document.AddFilterableValue("enddate", product.EndDate ?? DateTime.MaxValue); document.AddFilterableValue("createddate", product.CreatedDate); document.AddFilterableValue("lastmodifieddate", product.ModifiedDate ?? DateTime.MaxValue); document.AddFilterableValue("modifieddate", product.ModifiedDate ?? DateTime.MaxValue); document.AddFilterableValue("priority", product.Priority); document.AddFilterableValue("vendor", product.Vendor ?? ""); document.AddFilterableValue("productType", product.ProductType ?? ""); // Add priority in virtual categories to search index if (product.Links != null) { foreach (var link in product.Links) { document.AddFilterableValue($"priority_{link.CatalogId}_{link.CategoryId}", link.Priority); } } // Add catalogs to search index var catalogs = product.Outlines .Select(o => o.Items.First().Id) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); document.AddFilterableValues("catalog", catalogs); // Add outlines to search index var outlineStrings = GetOutlineStrings(product.Outlines); document.AddFilterableValues("__outline", outlineStrings); // Types of properties which values should be added to the searchable __content field var contentPropertyTypes = new[] { PropertyType.Product, PropertyType.Variation }; // Index custom product properties IndexCustomProperties(document, product.Properties, contentPropertyTypes); //Index product category properties if (product.Category != null) { IndexCustomProperties(document, product.Category.Properties, contentPropertyTypes); } //Index catalog properties if (product.Catalog != null) { IndexCustomProperties(document, product.Catalog.Properties, contentPropertyTypes); } if (product.Variations != null) { if (product.Variations.Any(c => c.ProductType == "Physical")) { document.Add(new IndexDocumentField("type", "physical") { IsRetrievable = true, IsFilterable = true, IsCollection = true }); IndexIsProperty(document, "physical"); } if (product.Variations.Any(c => c.ProductType == "Digital")) { document.Add(new IndexDocumentField("type", "digital") { IsRetrievable = true, IsFilterable = true, IsCollection = true }); IndexIsProperty(document, "digital"); } foreach (var variation in product.Variations) { document.Add(new IndexDocumentField("code", variation.Code) { IsRetrievable = true, IsFilterable = true, IsCollection = true }); // add the variation code to content document.Add(new IndexDocumentField("__content", variation.Code) { IsRetrievable = true, IsSearchable = true, IsCollection = true }); IndexCustomProperties(document, variation.Properties, contentPropertyTypes); } } if (StoreObjectsInIndex) { // Index serialized product document.AddObjectFieldValue(product); } return(document); }