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

  • Home
  • SEARCH
  • 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 8719053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:41:51+00:00 2026-06-13T06:41:51+00:00

Taking the Stack Overflow tagging system as the canonical example, how can I get

  • 0

Taking the Stack Overflow tagging system as the canonical example, how can I get back a tag object with its count?

Given these entities:

// Represents the data from the TagCount index
public class TagCount
{
    public string Tag { get; set; }
    public int Count { get; set; }
}

// Represents the data used to populate a tag-wiki
public class Tag
{
    public string Tag { get; set; }
    public DateTime Created  { get; set; }
    public string Description { get; set; }
}

public class Question
{
    // elided
    public List<string> Tags { get; set; }
    // elided
}

And the following definition of the TagCount index

// Map
from question in docs.Questions
from Tag in question.Tags
select new { Tag, Count = 1 }

// Reduce
from result in results
group result by result.Tag into g
select new 
{
    Tag = g.Key,
    Count = g.Sum(x=>x.Count)
}

On the tags page (e.g. https://stackoverflow.com/tags) we need to display a combination of the Tags collection and the TagCounts index. That is, we need to display the Tag.Name and Tag.Description from the Tags collection and TagCount.Count from the TagCount index. In SQL Server this would be achieved by a join, but this is obviously the relational way of thinking. What is the idiomatic RavenDB way of achieving this?

Is there a way to add a Count property to the Tag entity and have the index automatically update that property?

  • 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-13T06:41:52+00:00Added an answer on June 13, 2026 at 6:41 am

    You do that with patching, also called UpdateByIndex in the API.
    You can see this here:
    http://blog.hibernatingrhinos.com/12705/new-option-in-the-ravendb-studiondash-patching

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

Sidebar

Related Questions

Stack Overflow implemented its Related Questions feature by taking the title of the current
There are a lot of answers, here on Stack Overflow, on how to get
Thank you for taking the time to read this. I looked over Stack Overflow
Taking this file as an example, I'm trying to read the data in a
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
Taking a JavaScript object with 4 properties: function Object() { this.prop1; this.prop2; this.prop3; this.prop4;
Taking in consideration a table tbl_users , I want to get a list of
I remember a while ago on a Stack Overflow podcast Jeff Atwood was talking
Note: I couldn't decide whether this was more appropriate for Stack Overflow or Serverfault,
I imported the Stack Overflow data dump into SQL Server 2008. Some queries, especially

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.