Editing document using the Studio causes map reduce index behaving incorrectly

22 views
Skip to first unread message

Shohre Mansouri

unread,
May 23, 2013, 10:08:08 PM5/23/13
to rav...@googlegroups.com
This is our index:

Map:
from doc in docs where doc["@metadata"]["Raven-Entity-Name"] != null 
select new { Version = (doc["@metadata"]["Entity-Schema-Version"] ?? 0), Tag = doc["@metadata"]["Raven-Entity-Name"], Count = 1}

Reduce:
results.GroupBy(result => new {result.Version})
.Select(g => new {Version = g.Key.Version, Count = g.Count()})

So assume we queried the index like this:
Tag: OurDocuments

The result was:
Count      Version      Tag
10               1            OurDocuments

Once an issue happened and we had to edit a document using Management studio. The same query resulted as below. (the issue happens just when editing is done by using the studio)
Count      Version      Tag
9               1            OurDocuments
1               1            OurDocuments

What's happening here? Is there something we are doing wrong?

We are on RavenDB-Build-2330.

Regards,
Shohre



Oren Eini (Ayende Rahien)

unread,
May 24, 2013, 1:38:43 AM5/24/13
to ravendb
g.Count() is not allowed in indexes.
You need to use:

g.Sum(x=>x.Count);





--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Shohre Mansouri

unread,
May 24, 2013, 1:56:22 AM5/24/13
to rav...@googlegroups.com
Changed the Reduce to
results.GroupBy(result => new {result.Tag, result.Version}).Select(g => new {Tag = g.Key.Tag, Version = g.Key.Version, Count = g.Sum(x => x.Count)})
Still behaves the same.

Oren Eini (Ayende Rahien)

unread,
May 24, 2013, 1:59:01 AM5/24/13
to ravendb
Please create a failing test

Shohre Mansouri

unread,
May 24, 2013, 2:08:28 AM5/24/13
to rav...@googlegroups.com
Sure. I will try to get the http request sent when editing in Studio and replicate what's happening in a test.

Shohre Mansouri

unread,
May 27, 2013, 7:14:52 PM5/27/13
to rav...@googlegroups.com
Hi Oren,

I created a failing test, attached. And I know why the issue happens. The good thing is now we have a work around for it.
The thing is we save our custom metadata "Entity-Schema-Version" as an integer in the listener.
But when we edit anything in studio, the webrequest sent from the Studio sends the metadata as a string "1".
So when the index is grouping by version it sees two different things: 1 and "1".

Regards,
Shohre
EditingInStudioIssue.zip
Reply all
Reply to author
Forward
Message has been deleted
0 new messages