Issue when using an Id with type long and index defined by AbstractIndexCreationTask

19 views
Skip to first unread message

Julien D

unread,
Apr 16, 2012, 3:10:53 PM4/16/12
to ravendb
Hi everyone,

So far, I'm really having fun using RavenDB, very powerful and easy to
use.
But I have got an issue when using a long typed id and doing an index
on it, exemple :
public class TagDocument
{
public long Id { get; set; }
public string TagAmazon { get; set; }
public uint? TagDepartmentID { get; set; }
public string TagDescription { get; set; }
public bool TagHomepage { get; set; }
public string TagKeywords { get; set; }
public string TagName { get; set; }
public bool TagShow { get; set; }
public string TagTitle { get; set; }
}

With index :
public class TagDocument_ById :
AbstractIndexCreationTask<TagDocument, TagDocument>
{
public const string INDEX_NAME = "TagDocument/ById";

public TagDocument_ById()
{
Map = tags => from tag in tags
select new { tag.Id };
}
}

The index is created by with an error of type cannot convert from
string to long.

To solve this, I switched to int type and it works fine but what if I
really want a long type.

I'm using version 1.0.573 (maybe it's been fixed now, I'm gonna try
with a new build).

Best regards,
Julien

Oren Eini (Ayende Rahien)

unread,
Apr 17, 2012, 4:14:37 AM4/17/12
to rav...@googlegroups.com
Where do you see this error ? And what is the full error?

Julien D

unread,
Apr 20, 2012, 2:04:50 AM4/20/12
to ravendb
Hi,

Sorry for the delay but here is the answer.

The index created is this one following (code from the ravendb tool to
explore the database) :
docs.TagDocuments
.Select(tag => new {Id = ((long)tag.__document_id)})

On the bottom of the screen is written :
4 errors with an hyperlink and when i follow the link :
Cannot convert from string to long
4/20/2012 5:5734 AM
tagdocuments/2

(this is repeated again 3 times for the 3 others documents)

If I remove the cast to long is the index, it works fine but the index
is recreated with the cast as i start my application with the
AbstractIndexCreationTask.

Best regards,
Julien

On Apr 17, 10:14 am, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:

Oren Eini (Ayende Rahien)

unread,
Apr 20, 2012, 2:19:22 AM4/20/12
to rav...@googlegroups.com
Internally, ifs are string, you can't treat them as longs in the indexes

Julien D

unread,
May 12, 2012, 5:59:04 AM5/12/12
to rav...@googlegroups.com
Hello,

Thing is that it works fine with integer type (int) so there must be something to solve, isn't it ?

Oren Eini (Ayende Rahien)

unread,
May 12, 2012, 9:22:11 AM5/12/12
to rav...@googlegroups.com
No, it cheats on the client side to make it treat it as int, but it is NOT an int.
Reply all
Reply to author
Forward
0 new messages