Problem getting Pictures

76 views
Skip to first unread message

dredme

unread,
Jun 16, 2012, 4:21:01 AM6/16/12
to rav...@googlegroups.com
Hi,
I am trying to run this query:

RavenSession.Query<Picture>().Customize(x => x.WaitForNonStaleResults()).Where(c => c.ParentDocumentId == id && c.IsOfficial.Value).Select(c => new Picture
                                                                                  {
                                                                                      Name = c.Name,
                                                                                      Title = c.Title,
                                                                                      Url = c.Url,
                                                                                      Id = c.Id,
                                                                                      Description = c.Description,
                                                                                      IsMain = c.IsMain,
                                                                                  }).ToList();

But I get the following error:

Url: "/indexes/dynamic/Pictures?query=ParentDocumentId%253A7041%2520AND%2520IsOfficial.Value%253Atrue&start=0&pageSize=128&aggregation=None&fetch=Name&fetch=Title&fetch=Url&fetch=__document_id&fetch=Description&fetch=IsMain"
Index: "Temp/Pictures/ByIsOfficial_ValueAndParentDocumentId"

Index Temp/Pictures/ByIsOfficial_ValueAndParentDocumentId is invalid, out of 258 indexing attempts, 258 has failed.
Error rate of 100% exceeds allowed 15% error rate


Can anyone tell me what I'm doing wrong?


Oren Eini (Ayende Rahien)

unread,
Jun 16, 2012, 4:53:31 AM6/16/12
to rav...@googlegroups.com
Go into the studio and look at the errors.
Somehow, you have an index that throws errors, which is really strange.

What does it shows?

dredme

unread,
Jun 16, 2012, 7:10:37 AM6/16/12
to rav...@googlegroups.com
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'bool' does not contain a definition for 'Value'
   at CallSite.Target(Closure , CallSite , Object )
   at Index_Temp_2fPictures_2fByIsOfficial_ValueAndParentDocumentId.<.ctor>b__b(Object doc)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Raven.Database.Indexing.RobustEnumerator.MoveNext(IEnumerator en, StatefulEnumerableWrapper`1 innerEnumerator) in c:\Builds\RavenDB-Stable\Raven.Database\Indexing\RobustEnumerator.cs:line 84

בתאריך יום שבת, 16 ביוני 2012 11:53:31 UTC+3, מאת Oren Eini:

Oren Eini (Ayende Rahien)

unread,
Jun 16, 2012, 7:28:04 AM6/16/12
to rav...@googlegroups.com
Hm,
What does the index looks like?

dredme

unread,
Jun 16, 2012, 11:47:23 AM6/16/12
to rav...@googlegroups.com
I wrote a query in the first post above, when I run it I get this error about RavenDB didn't succeed creating the index for this query.
I'm using build #888

The paramaters ParectDocumentId is int and the IsOfficial parameter is a nullable bool



בתאריך יום שבת, 16 ביוני 2012 14:28:04 UTC+3, מאת Oren Eini:

Justin A

unread,
Jun 16, 2012, 8:08:19 PM6/16/12
to rav...@googlegroups.com
I'm no pro at this, but maybe convert the IsOfficial from bool? to bool. 

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2012, 3:06:01 AM6/17/12
to rav...@googlegroups.com
Can you show the actual index ?
And a sample document?

dredme

unread,
Jun 18, 2012, 8:02:57 AM6/18/12
to rav...@googlegroups.com
here is the index

from doc in docs.Pictures
select new { ParentDocumentId = doc.ParentDocumentId, IsOfficial_Value = doc.IsOfficial.Value, IsOfficial = doc.IsOfficial }

and here is a sample document
{
  "Title": null,
  "Filename": "D:\\uploads\\pictures\\634745902552916022_Hotel_7041_4368107104_71956ab061.jpg",
  "Url": "/uploads/pictures/634745902552916022_Hotel_7041_4368107104_71956ab061.jpg",
  "MediaType": null,
  "Description": null,
  "ParentDocumentId": 7041,
  "ParentDocumentType": "Hotel",
  "Username": "",
  "IsOfficial": true,
  "IsMain": null,
  "CreatedOn": "2012-06-06T14:37:35.4316102",
  "Name": null,
  "Status": "Published"
}

בתאריך יום ראשון, 17 ביוני 2012 10:06:01 UTC+3, מאת Oren Eini:

Oren Eini (Ayende Rahien)

unread,
Jun 18, 2012, 8:13:57 AM6/18/12
to rav...@googlegroups.com
You have this:
, IsOfficial_Value = doc.IsOfficial.Value 

The problem is that this is a boolean property, and bool doesn't have a Value property.
I assume it is a nullable boolean in your code?

dredme

unread,
Jun 18, 2012, 8:28:38 AM6/18/12
to rav...@googlegroups.com
yes it is

בתאריך יום שני, 18 ביוני 2012 15:13:57 UTC+3, מאת Oren Eini:

Oren Eini (Ayende Rahien)

unread,
Jun 18, 2012, 8:37:45 AM6/18/12
to rav...@googlegroups.com
Nullable bool isn't supported right now.
Try doing the query like this (just c.IsOfficial, not c.IsOfficial.Value)

RavenSession.Query<Picture>().Customize(x => x.WaitForNonStaleResults()).Where(c => c.ParentDocumentId == id && c.IsOfficial).Select(c => new Picture

                                                                                  {
                                                                                      Name = c.Name,
                                                                                      Title = c.Title,
                                                                                      Url = c.Url,
                                                                                      Id = c.Id,
                                                                                      Description = c.Description,
                                                                                      IsMain = c.IsMain,
                                                                                  }).ToList(); 

dredme

unread,
Jun 18, 2012, 10:25:00 AM6/18/12
to rav...@googlegroups.com
I have to change it to bool and not (bool?) in order for it to compile, but thats ok, it runs good that way.

בתאריך יום שני, 18 ביוני 2012 15:37:45 UTC+3, מאת Oren Eini:
Reply all
Reply to author
Forward
0 new messages