DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Extracting Data From Very Large XML Files With X-definition
  • What Is Ant, Really?
  • Couchbase: FTS Indexing Best Practices by Use Case
  • Couchbase: Improving Performance When Querying Multiple Arrays With FTS and N1QL

Trending

  • Hugging Face Is the New GitHub for LLMs
  • How TIBCO Is Evolving Its Platform To Embrace Developers and Simplify Cloud Integration
  • Breaking Down Silos: The Importance of Collaboration in Solution Architecture
  • Securing Your Applications With Spring Security
  1. DZone
  2. Culture and Methodologies
  3. Agile
  4. Index boosting in RavenDB

Index boosting in RavenDB

Oren Eini user avatar by
Oren Eini
·
Feb. 17, 12 · News
Like (0)
Save
Tweet
Share
4.37K Views

Join the DZone community and get the full member experience.

Join For Free

recently we added a really nice feature, boosting the results while indexing.

boosting is a way to give documents or attributes in a document weights. attribute level boosting is a way to tell ravendb that a certain  attribute in a document is more important than the others, so it will show up higher in queries when other properties are involved in a query. a document level boosting means that a certain document is more important than another (when using multi maps).

let us see a few examples where this is happening. the simplest scenario is when we have a multi field search, and we want one of the fields to be the more important one. for example, we decided that when you make a search for first name and last name, a match on the first name has higher relevance than a match on the last name. we can define this requirement with the following index:

public class users_byname : abstractindexcreationtask<user>
{
    public users_byname()
    {
        map = users => from user in users
                       select new
                       {
                           firstname = user.firstname.boost(3),
                           user.lastname
                       };
    }
}

and we can query the index using:

var matches = session.query<user,usersbyname>()
      .where(x=>x.firstname == "ayende" || x.lastname == "eini")
      .tolist()

assuming that we have a user with the first name “ayende” and another user with the last name “eini”, this will find both of them, but will rank the user with the name “ayende” first.

let us see another variant, we have a multi map index for users and accounts, both are searchable by name, but we want to ensure that accounts are more important than users. we can do that using the following index:

public class usersandaccounts : abstractmultimapindexcreationtask
{
    public usersandaccounts()
    {
        addmap<user>(users =>
                     from user in users
                     select new {name = user.firstname}
            );
        addmap<account>(accounts =>
                        from account in accounts
                        select new {account.name}.boost(3)
            );
    }
}

if we have query that has matches for users and accounts, this will make sure that the account comes first.

and finally, a really interesting use case is that based on the entity itself, you decide to rank it higher. for example, we want to rank customers that ordered a lot from us higher than other customers. we can do that using the following index:

public class accounts_search : abstractindexcreationtask<account>
{
    public accounts_search()
    {
        map = accounts =>
              from account in accounts
              select new
              {
                  account.name
              }.boost(account.totalincome > 10000 ? 3 : 1);
    }
}

this way, we get the more important customers first. and this is really one of those things that brings up the polish in the system, the things that makes the users sit up and take notice.

Database Document Use case Attribute (computing) Requirement Property (programming)

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Extracting Data From Very Large XML Files With X-definition
  • What Is Ant, Really?
  • Couchbase: FTS Indexing Best Practices by Use Case
  • Couchbase: Improving Performance When Querying Multiple Arrays With FTS and N1QL

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: