Searching in blocks

Vote:
 

Hi, 

we are trying to implement a search with EPiServer Find, On the site we are only able to find documentation on searching in pagedata, we need to search blocks aswell, and since we have a lot of shared blocks we need to find all pages where the block is added.

Anyone worked on a similar problem ?

#65052
Jan 18, 2013 12:11
Vote:
 

Hi,

You need to add the IndexInContentAreas attribute to the blocks that you want to be indexed when located on pages.

#65065
Jan 18, 2013 15:31
Vote:
 

Hey,

To elaborate a little on what Marcus wrote:

Shared blocks are indexed just as pages and you can search for shared blocks the same way as you do with pages. As for ContentAreas only references to the contents in them are indexed. For pages a method named SearchText is automatically indexed. This method returns the values of all properties marked as searchable AND all properties marked as searchable on content in ContentArea properties given that the content type is annotated with IndexInContentAreas.

In other words, if you have block types which are used for editorial content and you want pages with such blocks in content areas to be found when you search for a keyword in one of the blocks you should annotate the block with IndexInContentAreas. However, without knowing more about the site you're building, I'd advise you to think about wether that's what you actually want. If the blocks just hold "related" content which also exist on individual pages you may be better off not having the block content indexed on the pages.

#65079
Jan 18, 2013 23:24
Vote:
 

Is it possible to search the contents of block when using the basic EPiServer Search (used in for example Alloy tech demo site)? I did examine segments.gen (under "EPiServer/VPP/SiteName/Index/Main") with Luke (Lucene Index Toolbox) and it shows that the contents of Xhtml string in block is indexed but searchpage doesn't find it. Any ideas? Or would it be better to just use EPiServer Find? :)

#66192
Feb 22, 2013 13:42
Vote:
 

I would also like to know the answer to the previous question?

#74409
Aug 27, 2013 14:11
Vote:
 

Hello,
Vesa and Anssi i find in episerver blog an item with apparently a bad news

http://world.episerver.com/Blogs/Linda-Mohacsi/Dates/2013/6/The-built-in-EPiServer-search-functionality-described-in-a-non-technical-way/

(…)”Global search on all types of content, such as video, images etc. Not only pages and files. (There is one exception: you will not get hits on content in blocks that are added in a Content Area. This is usually not a problem though, since content in a block is often promoting content in a page, and that page will be found when performing the search. Searching in blocks is supported in EPiServer Find.)”(…)

If you find a solution, please help me,I have the same issue. i have use a lot of blocks for dynamized my pages and i have needed to return my blocks linked pages.

#74846
Sep 10, 2013 8:13
Vote:
 

Joel, what is the logic in collecting text from blocks in contentarea when "IndexInContentArea" is set? I tried adding custom "SearchText" to my block but that text is not added to the indexed content of the page to which this block is added to. How can I change that default behaviour?

#75598
Oct 01, 2013 9:42
Vote:
 

Hi Janne,

Properties that are searchable on the block will be included in the parent's (the page that contains the content area) SearchText().

#75599
Oct 01, 2013 9:50
Vote:
 

Yes, but my challenge is that I would like to have custom logic in block to return the SearchText for single block AND have that searchtext included to the parents indexed content? Do you see any way of achieving that? My block has custom logic of retrieving its content and this content is now not included to parents indexed content.

#75600
Oct 01, 2013 9:56
Vote:
 

Or should I do it so that I include my block also to the list of searched types and when matching block found get pages that use this block and then include those pages to the final results?

#75601
Oct 01, 2013 10:00
Vote:
 

Ah, what you have to do then is provide a custom implementation of the SearchText field on the parent object. A simple implementation may look something like this:

public class MyPage : PageData
{
  public virtual ContentArea MyStuff { get; set; }

  public string SearchText 
  {
    get 
    {
      var text = this.SearchText();
      foreach(var content in MyStuff.Contents)
      {
        var myBlock = content as MyBlock;
        if(myBlock != null)
        {
          text += " " + myBlock.SearchText;
        }
      }
      return text;
    }
  }
} 

You can of course make it more dynamic by iterating over all content area properties, but I hope the above code shows the essence of the solution?    

#75602
Oct 01, 2013 10:02
Vote:
 

Ok, this is what I originally had but I wanted to make it more general and place the custom SearchText to block instead so that it would get applied in all places where my block is added. But this is probably not duable this way? 

#75605
Oct 01, 2013 10:06
Vote:
 

Well, yes and no :) You could override SearchText for all your page types, either in a base class or by removing the default implementation and adding your own through the SearchClient.Convetions property. In your own implementation you could call the default implementation and then iterate over each of the page's properties and look for blocks in content areas.

One could definitely argue that the SearchText field should be used for blocks in content areas. However, if that was the case I think there may be a risk of circular references during indexing.

#75606
Oct 01, 2013 10:12
Vote:
 

I think I'll go with single page type implementation as a "quick" solution and look into the more general solution of having SearchText in base class later. Thanks a lot for the help and information!

#75607
Oct 01, 2013 10:17
Vote:
 

Hmm one more question: What is the way to call the default implementation for SearchText of a page?

#75609
Oct 01, 2013 10:34
Vote:
 

The default implementation is an extension method so given that you are in a PageData class: this.SearchText().

#75611
Oct 01, 2013 10:41
Vote:
 

Hey Joel, 'IndexInContentAreas' discussed above, is this still valid for EPiServer basic full text search? The results from shared blocks have no URL making it difficult for the visitors to judge the content source.

We also have problems with local blocks on pages not being indexed even properties in those blocks are marked as 'Searchable'. Annoyingly, a local block cannot be marked as searchable in code but in the admin mode you can enable a local block to be searchable but seems of no use as none of the properties in local blocks are indexed.

#79262
Dec 12, 2013 3:25
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.