I have a Sitecore 8.1 instance running with WeBlog and I want to be able to retrieve the Entry Date fields from Lucene. The Entry Date field is a Date Field.

My custom search result item class is defined like this:

public class BlogEntry: SearchResultItem
    public DateTime EntryDate { get; set; }

After reindexing the field is never populated with the right value when I run the query. Also, I have not created any custom index, I’m using the sitecore_web_index.

This is what my query looks like:

IQueryable<BlogEntry> searchQuery = searchcontext.GetQueryable<BlogEntry>()
    .Where(c => c.TemplateId == new ID("{5FA92FF4-4AC2-48E2-92EB-E1E4914677B0}") 
        && c.Path.Contains(DateTime.Now.Year.ToString()) 
        && c[BuiltinFields.LatestVersion] == "1" 
        && c.Language == Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName)

Any thoughts on what I need to change to have this field start populating with its value?

2 Answers 2


If what Gatogordo is suggesting doesn't work you might want to try adding a second entry in your index configuration with whitespaces because the value of the field may not be stored in the index even though the storage type of the field is set to YES in the configuration due to a known issue with Lucene search provide and fields with whitespaces. More info here.

In your case you want to have in the AddFieldByFieldName section the following:

<field fieldName="entry_date" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.DateTime" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
  <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />

<field fieldName="entry date" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
  <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />

Also, don't forget to rebuild your indexes after this change.

  • 1
    that was it. Used Luke just like Gatogordo suggested and found that the documents indexed were not getting the entry date field so adding these two entries and I started seeing them and getting the results
    – Arik Torhn
    Nov 29, 2018 at 15:01

You can verify your index with Luke (https://code.google.com/archive/p/luke/).

If you do, I think you wil notice that your entrydate field is in the index but not stored (storageType=NO) meaning that you can search on the field but not get the original value.

If this is indeed the case, you need to add your field to the index definition as stored. As you are using the default index, you need to patch the <defaultLuceneIndexConfiguration>.

Add a field to the <fieldMap>, something like:

<field fieldName="XXX" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.DateTime"settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
   <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />

ps: best to check the config in your solution to have the exact correct syntax for an extra field. Important part is the storageType="YES". This will tell the index to keep the original value available for retrieval.

You can verify all this again in Luke. Check your search logs for the query Sitecore is using. Open the index with Luke and try that query in the Search. Check the results.. to see if fields are stored or not, you can click on a result row to open this in the Documents tab where you get the list of all fields for this document with the "flags". The S flag indicates that the field is stored.

enter image description here

  • Does the field with name 'Entry Date' becomes 'entrydate' automatically? in that case I would need to use entrydate on the field declaration if I get this correctly?
    – Arik Torhn
    Nov 21, 2018 at 17:26
  • Best is to check your current index (with Luke) to see what fieldname was made.. Been a while since I used Lucene but I remember it was tricky with spaces.
    – Gatogordo
    Nov 21, 2018 at 17:30
  • Fairly certain it will replace spaces with underscores: [IndexField("entry_date")]
    – jrap
    Nov 21, 2018 at 17:54
  • @Gatogordo I have opened the index in luke and I do see that the field stored is entry_date and I see a lot of entries with the right data. I have also patched the config to have the field with storateType=Yes. I have rebuilt indexes as well but when I try to programatically load the field the entry_date is always coming empty from the index. Thoughts?
    – Arik Torhn
    Nov 22, 2018 at 1:23
  • Added to the answer how you can verify the index with Luke to see if it is really stored. Start by checking the search logs for the query.. if all is ok in the index, your mapping in the SearchResultItem could be wrong
    – Gatogordo
    Nov 22, 2018 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.