Document Scoring

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?


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