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 7837815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:51:31+00:00 2026-06-02T14:51:31+00:00

I am considering RavenDb to implement an ‘advanced faceted search’ scenario. I have to

  • 0

I am considering RavenDb to implement an ‘advanced faceted search’ scenario.
I have to deal with a complex hierarchical taxonomy and shared facets across the different branches of the tree while supporting full text search and all other basic features.

Is there any resource out there that document how to do this using the RavenDb API?

Insanely complex paper on the subject: Beyond Basic Faceted Search
Solr’s way: HierarchicalFaceting

  • 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-02T14:51:33+00:00Added an answer on June 2, 2026 at 2:51 pm

    Finally..

    using System.Collections.Generic;
    using System.Linq;
    using NUnit.Framework;
    using Raven.Abstractions.Data;
    using Raven.Client;
    using Raven.Client.Document;
    using Raven.Client.Indexes;
    using Raven.Client.Linq;
    
    namespace Prototype.Search.Tests
    {
        [TestFixture]
        public class HierarchicalFaceting
        {
            //
            // Document definition
            //
            public class Doc
            {
                public Doc()
                {
                    Categories = new List<string>();
                }
    
                public int Id { get; set; }
                public List<string> Categories { get; set; }
            }
    
            //
            // Data sample
            //
            public IEnumerable<Doc>  GetDocs()
            {
                yield return new Doc { Id = 1, Categories = new List<string> { "0/NonFic", "1/NonFic/Law"} };
                yield return new Doc { Id = 2, Categories = new List<string> { "0/NonFic", "1/NonFic/Sci" } };
                yield return new Doc { Id = 3, Categories = new List<string> { "0/NonFic", "1/NonFic/Hist", "1/NonFic/Sci", "2/NonFic/Sci/Phys" } };
            }
    
            //
            // The index
            //
            public class DocByCategory : AbstractIndexCreationTask<Doc, DocByCategory.ReduceResult>
            {
                public class ReduceResult
                {
                    public string Category { get; set; }
                }
    
                public DocByCategory()
                {
                    Map = docs =>
                          from d in docs
                          from c in d.Categories
                          select new
                                     {
                                         Category = c
                                     };
                }
            }
    
            //
            // FacetSetup
            //
            public FacetSetup GetDocFacetSetup()
            {
                return new FacetSetup
                           {
                               Id = "facets/Doc",
                               Facets = new List<Facet>
                                            {
                                                new Facet
                                                    {
                                                        Name = "Category"
                                                    }
                                            }
                           };
            }
    
            [SetUp]
            public void SetupDb()
            {
                IDocumentStore store = new DocumentStore()
                {
                    Url = "http://localhost:8080"
                };
                store.Initialize();
                IndexCreation.CreateIndexes(typeof(HierarchicalFaceting).Assembly, store);
    
                var session = store.OpenSession();
                session.Store(GetDocFacetSetup());
                session.SaveChanges();
    
                store.Dispose();
            }
    
            [Test]
            [Ignore]
            public void DeleteAll()
            {
                IDocumentStore store = new DocumentStore()
                {
                    Url = "http://localhost:8080"
                };
                store.Initialize();
    
                store.DatabaseCommands.DeleteIndex("Raven/DocByCategory");
                store.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery());
    
                store.Dispose();
            }
    
            [Test]
            [Ignore]
            public void StoreDocs()
            {
                IDocumentStore store = new DocumentStore()
                {
                    Url = "http://localhost:8080"
                };
                store.Initialize();
    
                var session = store.OpenSession();
    
                foreach (var doc in GetDocs())
                {
                    session.Store(doc);
                }
    
                session.SaveChanges();
                session.Dispose();
                store.Dispose();
            }
    
            [Test]
            public void QueryDocsByCategory()
            {
                IDocumentStore store = new DocumentStore()
                {
                    Url = "http://localhost:8080"
                };
                store.Initialize();
    
                var session = store.OpenSession();
    
                var q = session.Query<DocByCategory.ReduceResult, DocByCategory>()
                    .Where(d => d.Category == "1/NonFic/Sci")
                    .As<Doc>();
    
                var results = q.ToList();
                var facetResults = q.ToFacets("facets/Doc").ToList();
    
                session.Dispose();
                store.Dispose();
            }
    
            [Test]
            public void GetFacets()
            {
                IDocumentStore store = new DocumentStore()
                {
                    Url = "http://localhost:8080"
                };
                store.Initialize();
    
                var session = store.OpenSession();
    
                var q = session.Query<DocByCategory.ReduceResult, DocByCategory>()
                    .Where(d => d.Category.StartsWith("1/NonFic"))
                    .As<Doc>();
    
                var results = q.ToList();
                var facetResults = q.ToFacets("facets/Doc").ToList();
    
                session.Dispose();
                store.Dispose();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering that I have a Schema named SBST I want to find all empty
considering that each shipment takes two minutes and I have 500 users to send,
I am considering hosting my own RavenDB server and exposing it to the web.
Considering I have an array of objects, and all objects represent something out of
Considering I have two smartphones, A and B. If I am holding smartphone A,
considering we have following strings and we are going to write them into a
Considering the class below - can I do anything to implement a case-insensitive string?
Considering I have a continuous joint distribution of two independent normal random variables (let's
Considering the case, that I have the following menu: <ul> <li><a href=index.php>Index</a></li> <li><a href=about.php>About</a></li>
Considering I have admin access to a machine, can I remotely access the default

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.