Try our conversational search powered by Generative AI!

How to create custom object in index by convensions?

Vote:
 

I have five PageTypes that are exactly the same and I wan't them to be indexed as one object. I do it today by doing my own schedule job that do the indexing and a custom index of it in global.asax but I wan't to do it in the ContentIndexerConfig-class on some more smarter way. We are planning to make it one pagetype but there is a lot of work around that so it is not possible right now.

Are there any way to do this?

 

/Henrik

#77173
Nov 12, 2013 13:47
Vote:
 

Do you need them to be indexed as the same object or is it enough that you can search them as if they where the same? If thats the case you could extract an interface from your pagetypes and use that when searching.

#77224
Nov 13, 2013 10:28
Vote:
 

They are complex in the meaning that they inherit some properties from their parent if they havnt overritten it so the default serializer can't handle it so I have to do a custom part anyway,

#77229
Nov 13, 2013 12:05
Vote:
 

I found out how to do it. Here is my code:

ContentIndexer.Instance.Conventions.ForInstancesOf<ProduktbladGY>().ShouldIndex(ShouldIndexEducationPage);

private static bool ShouldIndexEducationPage(PageData page)
{
  var shouldIndex = page.CheckPublishedStatus(PagePublishedStatus.Published) && page.GetPropertyValue<string>("MetaRobots") != "NOINDEX, NOFOLLOW";
  var educationToIndex = page.ConvertToIndexObject();
  var find = new EPiServerFind();

  if (!shouldIndex)
  {
    try
    {
      SearchClient.Instance.Delete<EducationInfoToIndex>(page.PageGuid);
    }
    catch
    {
      //ignore
    }
  }
  else
  {
    try
    {
       SearchClient.Instance.Index(educationToIndex);
    }
    catch
    {
      //ignore
    }
  }

  return false;
}

    

I always returns false since I do not want to index the orginal Items.

#77481
Edited, Nov 20, 2013 9:31
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.
* 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.