I’m just starting to use SOLR integration with Sitecore 7. I was able to follow some guidelines and build a "POCO" class (inheriting from SearchResultItem) that allows me to execute LINQ queries and search data, as shown in the example below
public class MySearchItem: SearchResultItem
{
[IndexField("Text Field")]
public string TextField
{
get;
set;
}
[IndexField("Drop Link")]
public ID DropLink
{
get;
set;
}
[IndexField("Tree List")]
public IEnumerable<ID> TreeList
{
get;
set;
}
}
, , TextField DropLink , , TextField DropLink . TreeList, , null. , sitecore " " sitecore 7 IEnumerable .
var index = ContentSearchManager.GetIndex("sitecore_master_index");
using (var context = index.CreateSearchContext())
{
var results = context.GetQueryable<MySearchItem>();
results = results.Where(item => item.TemplateName == "Custom Sitecore Template");
}
. () [ "TreeList" ], , , . ?
, "POCO"? , . ? , TypeConverter , sitecore TreeList , , - ?
[IndexField("Tree List")]
public IEnumerable<TreeListItem> TreeList
{
get;
set;
}
/ .
!
, . , - , , , :
Sitecore.ContentSearch.Solr.Indexes.config:
<typeMatch typeName="guidCollection" type="System.Collections.Generic.IEnumerable`1[System.Guid]" fieldNameFormat="{0}_sm" multiValued="true" settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
<typeMatch typeName="stringCollection" type="System.Collections.Generic.IEnumerable`1[System.String]" fieldNameFormat="{0}_sm" multiValued="true" settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
<typeMatch typeName="intCollection" type="System.Collections.Generic.IEnumerable`1[System.Int32]" fieldNameFormat="{0}_im" multiValued="true" settingType="Sitecore.ContentSearch.SolrProvider.SolrSearchFieldConfiguration, Sitecore.ContentSearch.SolrProvider" />
, !