# Boosting specific documents to be at the top of the results

**URL:** <https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970>\
**Category:** Elasticsearch\
**Created:** [July 13, 2020, 12:47pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970 "2020-07-13T12:47:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![droplet](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@droplet](https://discuss.elastic.co/u/droplet)\
**Post date:** [July 13, 2020, 12:47pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/1 "2020-07-13T12:47:26Z")

</div>

Hi there,

I don't know how to best describe the topic, excuse the vague title.

I'm having some issue with the search results coming from an index.

The index contains about 1M+ documents (various products), but doing a text-search I get weird matching.

From those 1m+ products, there are about:

1000-1100 smartphones products,  
3200 smartphone LCD spare-parts,  
10k other smartphone related accessories.

It seems because the smartphone category contains less items than the other 2, I get mixed results. Is there a way to boost the smartphone products to come up a lot higher in the results and not get mixed results ?

for example, searching for "xiaomi redmi note 8"  
I get as a 1st result an LCD replacement screen product then 2-3 actual phones then some more LCD and batteries parts. The score between them is quite similar and it doesn't matter the actual phone you're looking for, because each phone "title" is included in those other categories, multiple times (OEM LCD for "model title", Original LCD for "model title", Protective Case for "model title", Car mount for "model title" etc.)

Please let me know what kind of information you need from me.

Running ES7.8 on Ubuntu 20.04

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 13, 2020, 4:16pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/2 "2020-07-13T16:16:13Z")

</div>

[This](https://discuss.elastic.co/t/customer-interest-related-keyword-search-in-elastic-search/235116/2) was a related subject which may be of interest

---

<div class="post-metadata">

**Author:** ![droplet](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@droplet](https://discuss.elastic.co/u/droplet)\
**Post date:** [July 13, 2020, 6:50pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/3 "2020-07-13T18:50:24Z")

</div>

Thanks for replying.

I checked those 2 links provided there about pinned and boosting queries. Seems unrealistic for my situation where my index currently contains 2.4m documents/products and my target is at 6-7m. I'm also a 1-man army and my app has 0 income. I should also edit the initial post to include other restrictions, like the app that I'm trying include the ES is a Laravel Framework app (Scout/ScoutElastic).

The "problematic" results tho occur for products that can have accessories, consumables, and/or repair-parts. Especially, if the "primary" product categories contain less items than the accessories for those primary categories, eg. Smartphones (1k products) vs. Smartphone Accessories (150k products). It is logical, I guess, that since the search terms appear more often in accessories, that the engine will score those higher.

Other examples include the following...  
Printers for example, have a lot of consumables.  
Laptops have repair parts and accessories.  
Phones have a $-ton more accessories and more repair parts than actual phone products.

Generally, any category of products you can think of that has accessories/repair-parts.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 13, 2020, 7:01pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/4 "2020-07-13T19:01:37Z")

</div>

> [@droplet](#):
>
> I'm also a 1-man army and my app has 0 income.

For down-boosting accessories/consumables [this comment](https://discuss.elastic.co/t/customer-interest-related-keyword-search-in-elastic-search/235116/12) may be relevant.

> "You can machine-learn the set of trigger keywords ..."

---

<div class="post-metadata">

**Author:** ![droplet](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@droplet](https://discuss.elastic.co/u/droplet)\
**Post date:** [July 13, 2020, 7:13pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/5 "2020-07-13T19:13:46Z")

</div>

This escalated quickly to machine-learning... 🤣

I wish I had the $$$ to hire an expert, but I'm just a PHP/Laravel app dev that is missing a great search experience on my app.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 14, 2020, 8:49am UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/6 "2020-07-14T08:49:59Z")

</div>

🙂

There's no worldly knowledge that ships with elasticsearch which makes it understand `iphone 64gb` is a better match than `iphone case` for an `iphone` search. You need to use the APIs we offer to add that sort of understanding.

> [@droplet](#):
>
> I wish I had the $$$ to hire an expert, but I'm just a PHP/Laravel app dev

Learning words associated with cases/covers etc isn't too hard. It's a single request. Here's an example using the [BestBuy query logs](https://www.kaggle.com/c/acm-sf-chapter-hackathon-big/data) .

```
GET bestbuykaggle/_search
{
  "query": {
	"match": {
	  "query": "case"
	}
  },
  "size": 0,
  "aggs": {
	"sample": {
	  "sampler": {
		"shard_size": 10000
	  },
	  "aggs": {
		"words associated with cases": {
		  "significant_text": {
			"field": "query",
			"size": 200
		  }
		}
	  }
	}
  }
} 

```

You can do this on your own data (query logs or product descriptions will do).  
This will give you a list of words like "iphone" that you should look for in all incoming user search strings and down-boost "case" matches on if the search string doesn't contain "case"

---

<div class="post-metadata">

**Author:** ![droplet](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@droplet](https://discuss.elastic.co/u/droplet)\
**Post date:** [July 16, 2020, 3:24pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/7 "2020-07-16T15:24:50Z")

</div>

I get it... while also not getting it.. 🤣

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 13, 2020, 3:24pm UTC](https://discuss.elastic.co/t/boosting-specific-documents-to-be-at-the-top-of-the-results/240970/8 "2020-08-13T15:24:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
