# Document Scoring

**URL:** https://discuss.elastic.co/t/document-scoring/285850
**Category:** Elasticsearch
**Tags:** painless, ingest-pipeline
**Created:** [October 4, 2021, 8:41pm UTC](https://discuss.elastic.co/t/document-scoring/285850 "2021-10-04T20:41:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leemase004](https://avatars.discourse-cdn.com/v4/letter/l/fbc32d/32.png) [@leemase004](https://discuss.elastic.co/u/leemase004)
#### Post date: [October 4, 2021, 8:41pm UTC](https://discuss.elastic.co/t/document-scoring/285850/1 "2021-10-04T20:41:19Z")

</div>

I know you can boost a fields score when running query (with the ^ symbol), but I am wondering if you can boost a fields score on/during ingestion when the data is initially coming into Elastic (via ingest pipelines or painless scripts).  
So as the documents come in, Elastic will view a specific field. If that field has a particular value then this document will receive a "score"

Example: Lets say we are a news paper company. We have a "Title" field for all of our headlines. Due to variety of headlines, we have the headlines field mapped as a text field.  
Title examples could be:  
"Cowboys comeback"  
"Yankees make the playoffs"  
"Lakers lose"  
"Patriots win Super Bowl"

We would want the script and/or ingest pipeline to read the Title field.  
If the Title mentions an NFL team (Cowboys and Patriots) It would received a "score" of 5.  
If the Title had a NBA team (lakers) a "score" of 3  
If the Title has a MLB team (yankees) a "score" of 1.

We would then map this new "score" field as a keyword and then the users could set up dashboards with the corresponding score.

How would we set up a pipeline and/or painless script to have elastic view a text field to find a certain amount of key words (from a dictionary file of sorts) and then either create a new field if there is a hit or assign a numeric score if there is a hit?

Thanks

---

<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: [November 1, 2021, 8:41pm UTC](https://discuss.elastic.co/t/document-scoring/285850/2 "2021-11-01T20:41:36Z")

</div>

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