Hello Renee,
By default you cannot set which items to be indexed. The NewsIndex gets all published IContent items from a given provider and the crawler gets all data. Then in our provider we build the news url. You can tweak the built-in news provider and implement filtering based on category or any other specific parameters you would like to use.
here is a sample code that will add only items from a certain category to the index
public
class
NewsIndexProviderCustom : Telerik.News.NewsIndexProvider
{
public
NewsIndexProviderCustom()
{
//
// TODO: Add constructor logic here
//
}
public
override
Telerik.Framework.Search.IIndexerInfo[] GetContentToIndex()
{
//return base.GetContentToIndex();
if
(
this
.retrievalMethod != RetrievalMethod.Direct)
return
new
IIndexerInfo[0];
if
(
this
.manager ==
null
)
throw
new
InvalidOperationException(
"Manager is null"
);
IMetaSearchInfo[] filter =
this
.manager.GetFilter(
this
.FilterExpression);
if
(ContentManager.Providers[DataProviderName].MetaKeys.ContainsKey(
"Category"
))
{
List<IMetaSearchInfo> newFilter =
new
List<IMetaSearchInfo>(filter);
MetaSearchInfo searchInfo =
new
MetaSearchInfo(MetaValueTypes.DateTime,
"Publication_Date"
,
"SomeName"
, SearchCondition.Equal);
newFilter.Add(searchInfo);
filter = newFilter.ToArray();
}
IList itemsList =
this
.manager.GetContent(0, 0, String.Empty, ContentStatus.Published,
this
.ParentIDs, filter);
List<IContent> lst =
new
List<IContent>();
foreach
(IContent cnt
in
itemsList)
{
if
(!lst.Contains(cnt))
lst.Add(cnt);
}
List<IIndexerInfo> data =
new
List<IIndexerInfo>(lst.Count);
foreach
(IContent content
in
lst)
{
if
(content !=
null
)
{
if
(
this
.manager.Provider.AllowLocalization)
{
foreach
(
string
lng
in
content.Languages)
{
CultureInfo cult = CultureInfo.GetCultureInfo(lng);
string
path =
this
.GetItemUrl(content,
this
.baseUrl, cult);
data.Add(
this
.GetIndexerInfo(path, content, cult));
}
}
else
{
string
path =
this
.GetItemUrl(content,
this
.baseUrl,
null
);
data.Add(
this
.GetIndexerInfo(path, content));
}
}
}
return
data.ToArray();
}
}
You can register the provider in your web.config
All the best,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items