ryanheath / RavenDB-NodaTime

Noda Time support for RavenDB
Other
20 stars 14 forks source link

no results in an index using LocalDate #9

Closed stevengopmo closed 8 years ago

stevengopmo commented 8 years ago

I have the following index that fails to return any documents in my database

from project in docs.Projects select new { Name = project.Name, GoLiveDate = NodaTimeField.Resolve(NodaTimeField.AsLocalDate(project.GoLiveDate)) }

The index saves fine but doesn't return any data at all unless I remove the "GoLiveDate" part.

The code equivalent of my index is

public class TaskIndex : AbstractIndexCreationTask<Project>
{
    public TaskIndex()
    {
        Map = projects => from project in projects
            select new
            {
                project.Name,
                GoLiveDate = project.GoLiveDate.AsLocalDate().Resolve()
            };

        Index(x => x.Name, FieldIndexing.Analyzed);
        Store(x => x.Name, FieldStorage.Yes);
        TermVector(x => x.Name, FieldTermVector.WithPositionsAndOffsets);
        Analyze(x => x.Name, "Raven.Database.Indexing.LowerCaseKeywordAnalyzer, Raven.Database");
        Index(x => x.GoLiveDate, FieldIndexing.Analyzed);
        Store(x => x.GoLiveDate, FieldStorage.Yes);
        TermVector(x => x.GoLiveDate, FieldTermVector.WithPositionsAndOffsets);
        Analyze(x => x.GoLiveDate, "Raven.Database.Indexing.LowerCaseKeywordAnalyzer, Raven.Database");
    }
}

The indexing and storing etc are just my random attempts at trying to find out why I never get any results.

Here is what my documents look like

{ "Name": "Some Project", "Description": "Some Description", "ProjectType": "New", "GoLiveDate": { "ticks": 14523840000000000, "calendar": "ISO" }, }

and the c# version

public class Project : Entity
{
    public string Name { get; set; }
    public string Description { get; set; }
    public ProjectTypes ProjectType { get; set; }
    public LocalDate GoLiveDate { get; set; }
}

I'm not even trying to actually filter anything just view the documents in the index. I'm using RavenDB version 3

My bundle settings look like

{
"Id": "goPMO.Impel",
"Settings": {
    "Raven/ActiveBundles": "NodaTime",
    "Raven/DataDir": "~\\goPMO.Impel"
},
"SecuredSettings": {},
"Disabled": false
}

If there is anything additional that I can give you to help me troubleshoot this I will. Thank you very much.

stevengopmo commented 8 years ago

I finally managed to find the logs and they say

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'Raven.Bundles.NodaTime.Indexing.NodaTimeField.AsLocalDate(string)' has some invalid arguments
at CallSite.Target(Closure , CallSite , Type , Object )
at Index_TaskIndex.<.ctor>b__c(Object project)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Raven.Database.Indexing.RobustEnumerator.MoveNext(IEnumerator en, StatefulEnumerableWrapper`1 innerEnumerator)

That doesn't tell me anything does it you?

stevengopmo commented 8 years ago

looks like I forgot to call ConfigureForNodaTime on the store. Sorry for the confusion