我的项目我正在使用Sitecore7 MVC,Solr和Glass。
"ContentSearch“索引包含了几乎所有在sitecore模板中使用的字段。我正在使用GlassMapper类作为我的模型(它几乎什么都不包含,只包含属性,这些属性是sitecore字段)并对其进行查询。基本操作“使用自定义结果类”,如下所述:http://glass.lu/docs/tutorial/sitecore/tutorial25/tutorial25.html
就像它应该做的那样。
我的问题是:
它是否使用Solr索引填充类属性(通常是sitecore字段),只要索引存在(这正是我想要的)?
或
它要去塞特罗尔得到场值吗?(我认为这是效率低下的,在这种情况下,我将编写自定义类并循环它们来填充glassMapper类,因为在我的视图中,我使用了GlassMapper类作为我的模型)
例如,我的一个模型如下所示:
[SitecoreType]
public class MyAwesomeModel
{
[SitecoreId]
[IndexField("_id")]
public virtual Guid Id { get; set; }
[SitecoreInfo(SitecoreInfoType.Language)]
[IndexField("_language")]
public virtual string Language { get; set; }
[TypeConverter(typeof(IndexFieldItemUriValueConverter))]
[XmlIgnore]
[IndexField("_uniqueid")]
public virtual ItemUri Uri { get; set; }
[SitecoreInfo(SitecoreInfoType.Version)]
public virtual int Version
{
get
{
return Uri == null ? 0 : Uri.Version.Number;
}
}
[SitecoreField(FieldName="MyRichtextField")]
[IndexField("MyRichtextField")]
public virtual string RichTextContent { get; set; }
[SitecoreInfo(SitecoreInfoType.Url, UrlOptions = SitecoreInfoUrlOptions.LanguageEmbeddingNever)]
public virtual string Url { get; set; }
}发布于 2014-07-16 09:31:57
实际上,我只是把一些代码推到了我的Glass.Mapper叉中,这样做是正确的:https://github.com/csteeg/Glass.Mapper (在开发分支中)
您必须修补您的配置,所以您将使用特定于玻璃的内容搜索设置:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
<indexDocumentPropertyMapper>
<objectFactory type="Sitecore.ContentSearch.DefaultDocumentMapperObjectFactory, Sitecore.ContentSearch">
<patch:attribute name="type">Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassDocumentMapperObjectFactory, Glass.Mapper.Sc.ContentSearch.LuceneProvider</patch:attribute>
</objectFactory>
</indexDocumentPropertyMapper>
</defaultLuceneIndexConfiguration>
</indexConfigurations>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="sitecore_master_index">
<patch:attribute name="type">Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassLuceneIndex, Glass.Mapper.Sc.ContentSearch.LuceneProvider</patch:attribute>
</index>
<index id="sitecore_web_index">
<patch:attribute name="type">Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassLuceneIndex, Glass.Mapper.Sc.ContentSearch.LuceneProvider</patch:attribute>
</index>
<index id="sitecore_core_index">
<patch:attribute name="type">Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassLuceneIndex, Glass.Mapper.Sc.ContentSearch.LuceneProvider</patch:attribute>
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>代码首先从索引返回值(如果它们存储在索引中)。如果请求一个没有存储在索引中的属性,它将从Sitecore项中获取值。
https://stackoverflow.com/questions/24776191
复制相似问题