Пользовательский индекс Sitecore - ПРЕДУПРЕЖДЕНИЕ Не удалось сопоставить индексный документ (поле: _uniqueid - PullRequest
0 голосов
/ 25 мая 2019

Я создал свой собственный индекс в Sitecore с помощью FlatDataCrawler.

Индекс создан, и я могу видеть свои документы в Solr.

Проблема заключается в том, что всякий раз, когда я пытаюсьполучить эти документы в моем коде, я вижу исключение как это:

Object reference not set to an instance of an object.

И в файле журнала sitecore я вижу это ПРЕДУПРЕЖДЕНИЕ:

ManagedPoolThread #4 14:29:09 INFO  Solr Query - ?q=*:*&rows=1000000&fq=_indexname:(products_index)&wt=xml
ManagedPoolThread #4 14:29:09 WARN  Could not map index document (field: _uniqueid; Value: fae308d2-233f-4f7f-a4fd-9d880e42ff13) - Object reference not set to an instance of an object.

Это моя конфигурация индекса:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
    <sitecore role:require="Standalone or ContentManagement" search:require="solr">
        <contentSearch>
            <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
                <indexes hint="list:AddIndex">
                    <index id="products_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                        <param desc="name">$(id)</param>
                        <param desc="core">$(id)</param>
                        <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
                        <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
                            <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
                                <indexAllFields>false</indexAllFields>
                            </documentOptions>
                        </configuration>
                        <strategies hint="list:AddStrategy">
                            <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/manual" />
                        </strategies>
                        <locations hint="list:AddCrawler">
                            <crawler type="Feature.ProductsIndex.Crawlers.CustomOrderCrawler, Feature.ProductsIndex" />
                        </locations>
                    </index>
                </indexes>
            </configuration>
        </contentSearch>
    </sitecore>
</configuration>

Это мой код:

using (var searchContext = ContentSearchManager.GetIndex("products_index").CreateSearchContext()) 
{
    int count = searchContext.GetQueryable<SearchResultItem>().Count(); //This works        
    var results = searchContext.GetQueryable<SearchResultItem>().ToList(); //Exception here!    
}

1 Ответ

0 голосов
/ 28 мая 2019

См. В файле схемы, если у вас есть

<uniqueKey>_uniqueid</uniqueKey>
<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>

если не перейти по этой ссылке заполнить схему solr , перезапустить службу solr и затем попытаться перестроить индекс

...