We have updated to RavenDB 1.2.2137 (from 1.2.2084) and have had an index fail unexpectedly.
We traced it down to the usage of string.IsNullOrEmpty() in a specific case.
Having replaced the usage of
string.IsNullOrEmpty(c.PropertyName)
with
“c.PropertyName == null || c.PropertyName.Trim().Length == 0,
the index works again.
We have failing tests, but a fail test could not reproduce the situation outside of our current context.
Concrete the lines of code, which had to be replaced, can be seen below.
Does anybody have an idea what could cause such behaviour?
class ContactDto_Index : AbstractIndexCreationTask<ContactDto, ContactDto_Index.Result>
{
public class Result{
…
public string LegalEntityNameOrder { get; set; }
public bool HasLabel { get; set; }
…
}
Map = content => from c in content
select new
{
…
Broken:
//LegalEntityNameOrder = string.IsNullOrEmpty(c.LegalEntityName) ? "zzzzzzz" : c.LegalEntityName,
Works:
LegalEntityNameOrder = c.LegalEntityName == null || c.LegalEntityName.Trim().Length == 0 ? "zzzzzzz" : c.LegalEntityName,
Did not need change:
HasLabel = !string.IsNullOrEmpty(string.Join("", c.LegalEntityName, c.SurName, c.FirstName, c.SecondName).Trim())
…
}
Index(x => x.LegalEntityNameOrder, FieldIndexing.Analyzed);
Sort(x => x.LegalEntityNameOrder, SortOptions.String);
Analyzers.Add(x => x.LegalEntityNameOrder, currentCollationAnalyzer);
…
}