Only index objects with specific property value


I have an index in dire need of some cleaning due to lack of free space.

I want to index only objects of a specific type with correct value on a property.

I have built an extension method for GenericMedia to filter if it is of a certain type:

public static bool IsBlue(this T content)
			var iContent = content as IContent;

			if (iContent != null)
				//fancy logic
				return boolean;

			return false;


SearchClient.Instance.Conventions.ForInstancesOf().IncludeField(x => x.IsBlue());

This property is used when filtering the search.

Since only a fraction of the indexed Generic Media objects actually have true value on on the property IsBlue, I see no reason to index those who do not.

How do I index only these blue objects?

I was thinking of something along these lines:

ContentIndexer.Instance.Conventions.ForInstancesOf().ShouldIndex(x => false);
			ContentIndexer.Instance.Conventions.ForInstancesOf().Where(x => x.IsBlue()).ShouldIndex(x => true);

But, the syntax is all wrong. So, do any you know how to solve this problem?

Thanks for helping.

Feb 10, 2016 14:19

Hi Hannes,

Does it work if you create an extension method like this:

public static class GenericMediaExtensions
    public static bool IsBlue(this GenericMedia content)
        // fancy logic

And then use this:

                .ShouldIndex(x => x.IsBlue());
Feb 10, 2016 14:53

Great idea, I will try it and get back to you.

Feb 15, 2016 10:18
* 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.