SelectMany with string array

Vote:
 

Is there a way to make the values of a SelectMany-attributed property be stored as an string array instead of a string?

We have a soultion which uses VulcanSearch and since the value is stored as "string1,string2,string3" it makes the search in those fileds troublesome. Read that for elasticsearch you can fix this by specifying an analyzer for that field that automatically sperates it by comma but I'm not sure how that would be implemented using the Project Vulcan setup.

#157876
Sep 23, 2016 17:09
Vote:
 

Add another property on contenttype that reads from first and returns a string array...?

#157880
Sep 23, 2016 18:20
Ted
Vote:
 

I think Daniel's suggestion is a viable option, or you could customize the indexing if you don't want to modify your original object: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Indexing/

#157885
Sep 24, 2016 19:09
Vote:
 

It's amazing how you sometimes don't see the the simple solutions for problems. Thanks for the input! Another property will solve this nicely.

#158252
Sep 26, 2016 10:19
Vote:
 

Isn't it...? :)

Extension method for the content type is a slightly more elegant way of doing the same if you don't want to mess with your model btw. 

#158253
Sep 26, 2016 11:02
Vote:
 

Yes that would probably be a better, I just have to figure out how to set that up with Vulcan.

#158255
Sep 26, 2016 11:25
Vote:
 

Solved it for now using the following setup (adding a property on the page object):

[Display(
            GroupName = GroupNames.TechnicalInformation,
            Order = 700)]
        [CategorySelectMany("HouseProperties", SelectionFactoryType = typeof(CategorySelectionFactory))]
        public virtual string HousePropertiesString { get; set; }

        public IEnumerable<string> HouseProperties
        {
            get
            {
                var properties = this.GetPropertyValue(p => p.HousePropertiesString);
                if (string.IsNullOrEmpty(properties)) return new List<string>();
                return properties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }
        }
#158258
Sep 26, 2016 11:56
Vote:
 

Tobias,

You can also add custom fields by implementing an IVulcanIndexingModifier. I've done that to add isSearchable to a page type in a nuget assembly. Here is a sample:

        public void ProcessContent(IContent content, Stream writableStream)
        {
            if (content == null)
                return;

            string searchDescription;
            GetDescription(content, out searchDescription);

            // fallback to teaser
            if (string.IsNullOrWhiteSpace(searchDescription) && content is SitePageData)
                searchDescription = ((SitePageData)content).Teaser;

            var streamWriter = new StreamWriter(writableStream);

            if (!string.IsNullOrWhiteSpace(searchDescription))
                streamWriter.Write(",\"" + VulcanFieldConstants.SearchDescriptionField + "\": " + Escape(searchDescription));

            // Add IsSearchable 
            if (content is BlogPostData)
                streamWriter.Write(",\"isSearchable\": true");

            streamWriter.Flush();

        }
#159729
Sep 27, 2016 22:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.