Sitefinity / feather

mvc
Other
97 stars 68 forks source link

Add custom widget content in search index #1523

Closed David-Heylbroeck closed 9 years ago

David-Heylbroeck commented 9 years ago

Hello,

I have several custom widget in my sitefinity project and I want to add the properties of my custom widgets in the search index. To do that I try to implement the interface "IContentLocatableView" without success.

Find here the properties in the controller of my custom widget : public string Title { get; set; } public string SubTitleParagraphs { get; set; }

Find here the implementation of the GetLocations method and DisableCanonicalUrlMetaTag (For the ContentType I try "PageData", "PageNode", and my latest test with the widget controller type) :

    public IEnumerable<IContentLocationInfo> GetLocations()
    {
        var location = new ContentLocationInfo()
        {
            ContentType = TypeResolutionService.ResolveType("SitefinityWebApp.Mvc.Controllers.CbbParagraphController"),
            //Priority = ContentLocationPriority.Highest,
            ProviderName = PageManager.GetDefaultProviderName()
        };

        yield return location;
    }
    public bool? DisableCanonicalUrlMetaTag
    {
        get { return _disableCanonicalUrlMEtaTag; }
        set { _disableCanonicalUrlMEtaTag = value; }
    }
    private bool? _disableCanonicalUrlMEtaTag = false;

What's wrong with my implementation

Thank you in advance for your help

David.

Boyko-Karadzhov commented 9 years ago

Hello David,

The view that is rendered by the widget should be indexed without the need of implementing IContentLocatableView. Indexes that index pages should be able to find whatever the widget has rendered in its Index action.

We use IContentLocatableView to tell Sitefinity that a particular content (News item for instance) is located on the page where the widget is dropped so when a user searches and finds a text that is contained in the content then the link in the search results will point to a page where this content is located.

Regards, Boyko

David-Heylbroeck commented 9 years ago

Hello Boyko,

I made several tests and my pages is well indexed because when I start typing the title of one page the auto-complete works fine, but when I try to typing some widget content in the search box the auto-complete displayed nothing

Regards,

David.

Boyko-Karadzhov commented 9 years ago

Hello David,

The content of the pages might be left out of the index. Check in the properties of the search index if "Static HTML in pages" checkbox is checked.

You can test it by placing a content block with some text in it on a page. If you search for that text you should be able to get a result for the respective page.

If you can find a text from content block but cannot find widget content from your custom widget on another page then there might be an issue in the widget. You can check ~/App_Data/Sitefinity/Logs/Error.log for an exception coming from the widget.

Regards, Boyko

David-Heylbroeck commented 9 years ago

Hello Boyko,

As you can see in the print screen below I test the search index :

  1. the search index is set on Static HTML in pages.
  2. The search box is set on the search index setup on point 1
  3. I put on another page a content block widget with "David test" inside the content.
  4. I search David on the search box (no autocomplete) and when I navigate to the search results page there is no results for David.

So the search is not working with my custom widget and with contenty block out of the box widget.

contentblocksettings searchboxsettings searchindexsettings searchnoresult searchresultssettings

Regards

David.

PepiIvanova commented 9 years ago

Hello David,

Could you please check if you can reproduce the issue with the Web Form (Sitefinity) Search box widget? Regarding autocomplete, check Search box SuggestionFields property (from Advanced > Model). By default this property is set to Title, Content. Most probably you need to add another field that will be used by the search box's autcomplete.

Best, Pepi

ElenaGaneva commented 9 years ago

Hello David,

I tested the issue and I believe that it is caused by a missing search segment file . In order to resolve this I can suggest you reindex MainSerach index. This could be achieved by backend->Administration->Search indexes, find your search index and from Actions dropdown choose Reindex.

If the issue still persist after the reindex please let me know.

Regards, Elena