question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I boost a field and not a term ?

See original GitHub issue

I am building an index which has several fields (name, make, OEM name and description)

E.g

ID: 1
Name: Wrench
Make: Test
OEM Name: Wrench 123
Description: Nice wrench

ID: 2
Name: Allen Wrench
Make: Rick
OEM Name: null
Description: It's a good one!

So when I search for allen wrench, given that the word wrench is in name, oem name and description it makes sense that the first result is ID 1.

However I want to specify that the field Name has an extra boost so that when I search for allen wrench ID 2 will be the first result.

Is that possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

23reactions
olivernncommented, Jun 23, 2018

I’ve just released version 2.3.0 which now re-introduces field boosts as well as adding document boosts. Documentation is being updated, I will updated the guides at some point too, but this is what the interface looks like:

var idx = lunr(function () {
  this.ref('id')
  this.field('title', { boost: fieldBoost })
  this.field('body')

  documents.forEach(function (doc) {
    this.add(doc, { boost: documentBoost })
  }, this)
})
8reactions
knlodhacommented, Nov 24, 2017

@olivernn Can we have field specific boosting available in lunr 2.0 similar to what we used to have in lunr 1.0. Suppose, if we have 2 fields like ‘title’ and ‘body’ and we want to boost results which have queries matched in ‘title’ over the queries matched in ‘body’ , we cannot achieve it using term level boosting. Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boost — Haystack 2.4.1 documentation
Term boost happens at query time (when the search query is run) and is based around increasing the score if a certain word/phrase...
Read more >
solr - How to down boost a term in dismax - Stack Overflow
Boosting on qf parameter will boost the field regardless of value in the field. In order to boost documents that contains the keyword...
Read more >
Cross_fields and boost - Is it feasible? - Elasticsearch
Note that cross_fields is usually only useful on short string fields that all have a boost of 1. Otherwise boosts, term freqs and...
Read more >
Relevance Tuning Guide, Weights and Boosts - Swiftype
Boosts · Value Boost: Applies to text, number, and date fields. A value boost looks for a specific value within a given field....
Read more >
Field Boost - Bee Swarm Simulator Wiki - Fandom
Multiple sources of field boosts can be used to reach much higher stacks. ... the boost in pollen will still be there, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found