Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damien 36 posts 162 karma points
    Apr 05, 2018 @ 11:37
    Damien
    0

    Multilingual dynamic search provider & index

    Hi,

    Great package, working well.

    I would like to pass in the search provider and index in my controller and from a view.

    What would be the best way to do this:

    var browser = BrowseManager.Browser

    Currently these properties are set in the MyBrowser class and only have a getter.

    Many Thanks Damo

  • Tom Steer 161 posts 596 karma points
    Apr 23, 2018 @ 09:12
    Tom Steer
    0

    Hey Damo,

    Because we hook into the DocumentWriting event on app startup we need to know of the indexes at this point, so we can ensure the fields are indexed properly for faceting. So currently it wouldn't be possible to switch out the index provider in your controller.

    I think the only way would be to have multiple browsers for each of your indexes.

    Cheers, Tom

  • Damien 36 posts 162 karma points
    Apr 26, 2018 @ 13:08
    Damien
    0

    Hi Tom,

    Thanks for getting back to me, that's understandable no worries, on a separate point, if I'm using a MNP for my categories/facets will i need to hook into gathering node data event to get the string value into the Lucene index (as it just stores the content node id's) or is there anything else i can override in BoBo facets to facilitate this? Any examples you might have appreciated.

    Thanks again Damo

  • Damien 36 posts 162 karma points
    May 03, 2018 @ 10:51
    Damien
    0

    Did this in the end:

    private void BrowserIndexer_DocumentWriting(IEnumerable<IFacetField> facetFields, object sender, DocumentWritingEventArgs e, UmbracoHelper helper)
        {
            var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
    
            IContentType contentType = contentTypeService.GetContentType(e.Fields["nodeTypeAlias"]);
            IEnumerable propertyTypes = contentType.CompositionPropertyTypes;
    
            foreach (var facetField in facetFields)
            {
                if (e.Fields.ContainsKey(facetField.Alias))
                {
                    var facetValue = e.Fields[facetField.Alias];
    
                    foreach (PropertyType propertyType in propertyTypes)
                    {
                        if (propertyType.Alias == facetField.Alias && propertyType.PropertyEditorAlias == "Umbraco.MultiNodeTreePicker2")
                        {
                            foreach (var value in facetField.PrepareForIndex(facetValue))
                            {
                                Udi udi;
    
                                if (Udi.TryParse(value, out udi))
                                {
                                    e.Document.Add(facetField.CreateIndexField(helper.TypedContent(udi).Name));
                                }
                            }
    
                        }
                        else if (propertyType.Alias == facetField.Alias)
                        {
                            foreach (var value in facetField.PrepareForIndex(facetValue))
                            {
                                e.Document.Add(facetField.CreateIndexField(value));
                            }
                        }
                    }
    
                }
            }
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft