chriseldredge / Lucene.Net.Linq

LINQ provider to run native queries on a Lucene.Net index
Other
151 stars 66 forks source link

IEnumerable<string> and StartsWith #95

Open anantakrishna opened 8 years ago

anantakrishna commented 8 years ago

I want to store date tags for my resources in a separate field of the document in the form of 'yyyyMMdd'. There may be many tags for single document. So my setup is as follows:

public class Resource
{
        //…
        public IEnumerable<string> DateTags { get; set; }
}

…
map.Property(r => r.DateTags).ToField("DateTag").NotAnalyzedNoNorms();

And I need to query all the documents that belongs to particular year, for example. I'm trying to utilize StartsWith but with no success.

var items = provider.AsQueryable(map.ToDocumentMapper()).Where(r => r.DateTags.Any(dt => dt.StartsWith("1999")));

This query always return all the documents. What am I doing wrong?