Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:46:17+00:00 2026-06-15T17:46:17+00:00

This post goes some way to answering this question (I’ll include the answer later),

  • 0

This post goes some way to answering this question (I’ll include the answer later), but I was hoping for some further details.

We have a number of applications that each need to access/manipulate data from Raven in their own way. Data is only written via the main web application. Other apps include batch-style tasks, reporting etc. In an attempt to keep each of these as de-coupled as possible, they are separate solutions.

That being the case, how can I, from the reporting application, create indexes over the existing data, using my locally defined types?

The answer from the linked question states

As long as the structure of the classes you are deserializing into partially matches the structure of the data, it shouldn’t make a difference.

The RavenDB server doesn’t care at all what classes you use in the client. You certainly could share a dll, or even share a portable dll if you are targeting a different platform. But you are correct that it is not necessary.

However, you should be aware of the Raven-Clr-Type metadata value. The RavenDB client sets this when storing the original document. It is consumed back by the client to assist with deserialization, but it is not fully enforced

It’s the first part of that that I wanted clarification on. Do the object graphs for the docs on the server and types in my application have to match exactly? If the Click document on the server is

{
  "Visit": {
    "Version": "0",
    "Domain": "www.mydomain.com",
    "Page": "/index",
    "QueryString": "",
    "IPAddress": "127.0.0.1",
    "Guid": "10cb6886-cb5c-46f8-94ed-4b0d45a5e9ca",
    "MetaData": {
      "Version": "1",
      "CreatedDate": "2012-11-09T15:11:03.5669038Z",
      "UpdatedDate": "2012-11-09T15:11:03.5669038Z",
      "DeletedDate": null
    }
  },
  "ResultId": "Results/1",
  "ProductCode": "280",
  "MetaData": {
    "Version": "1",
    "CreatedDate": "2012-11-09T15:14:26.1332596Z",
    "UpdatedDate": "2012-11-09T15:14:26.1332596Z",
    "DeletedDate": null
  }
}

Is it possible (and if so, how?), to create a Map index from my application, which defines the Click class as follows?

class Click
{
    public Guid Guid {get;set;}
    public int ProductCode {get;set;}
    public DateTime CreatedDate {get;set;}
}

Or would my class have to be look like this? (where the custom types are defined as a sub-set of the properties on the document above, with matching property names)

class Click
{
    public Visit Visit {get;set;}
    public int ProductCode {get;set;}
    public MetaData MetaData {get;set;}
}

UPDATE

Following on from the answer below, here’s the code I managed to get working.

Index

public class Clicks_ByVisitGuidAndProductCode : AbstractIndexCreationTask
{
    public override IndexDefinition CreateIndexDefinition()
    {
        return new IndexDefinition
            {
                Map =
                    "from click in docs.Clicks select new {Guid = click.Visit.Guid, ProductCode = click.ProductCode, CreatedDate = click.MetaData.CreatedDate}",
                TransformResults =
                    "results.Select(click => new {Guid = click.Visit.Guid, ProductCode = click.ProductCode, CreatedDate = click.MetaData.CreatedDate})"
            };
    }
}

Query

var query = _documentSession.Query<ReportClick, Clicks_ByVisitGuidAndProductCode>()
                            .Customize(x => x.WaitForNonStaleResultsAsOfNow())
                            .Where(x => x.CreatedDate >= start.Date && x.CreatedDate < end.Date);

where Click is

public class Click
{
    public Guid Guid { get; set; }
    public int ProductCode { get; set; }
    public DateTime CreatedDate { get; set; }
}

Many thanks @MattJohnson.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:46:18+00:00Added an answer on June 15, 2026 at 5:46 pm

    The shape is a partial match, then it will fill in where it can, so your second example would work ok.

    You can, however, create an index that projects the results you’re showing in your first example. You would map by whatever you actually were going to filter or sort by, and then you would add a TransformResults section:

    TransformResults = (database, clicks) =>
        from click in clicks
        select new {
            click.Visit.Guid,
            click.ProductCode,
            click.MetaData.CreatedDate
        };
    

    When you query this index, it will come out in the shape you specified in the transform. This is a features called “Live Projections”, which you can read more about here. (You won’t need an .As() call, just use .Query<Click, YourIndex>() and it should work fine.)

    Separately – what are you doing with MetaData is extraneous. Raven keeps metadata separated from the document. Read more on metadata here.

    It looks like you have versioning concerns. If you are just keeping an audit trail, you should look at Raven’s standard Versioning Bundle. If you have temporal effectivity concerns, consider using my new Temporal Versioning Bundle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post asks this question but doesn't really give an answer, so I thought
i have a small problem here which i cannot fix,This post goes through but
This post started as a question on ServerFault ( https://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined
This goes back to my other question which I thought was sufficiently answers but
im not sure this is a good question to post but here is my
Hopefully this post goes better.. So I am stuck on this feature of this
I saw this post on Sitepoint quoting a statement by Rasmus Lerdorf which goes
This post if a follow-up question to mt previous post: Android RESTful Web application
So some code in MainApp.py goes like this, the lines I am concerned about
This is probably going to be more of a discussion or hypothetical question, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.