# Compute similarty score while ingesting data

**URL:** <https://forum.opensearch.org/t/compute-similarty-score-while-ingesting-data/4575>\
**Category:** k-NN\
**Created:** [January 14, 2021, 9:26am UTC](https://forum.opensearch.org/t/compute-similarty-score-while-ingesting-data/4575 "2021-01-14T09:26:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wassim.dhib](https://avatars.discourse-cdn.com/v4/letter/w/e9bcb4/32.png) [@wassim.dhib](https://forum.opensearch.org/u/wassim.dhib)\
**Post date:** [January 14, 2021, 9:26am UTC](https://forum.opensearch.org/t/compute-similarty-score-while-ingesting-data/4575/1 "2021-01-14T09:26:26Z")

</div>

Hi,

I have a pipeline which contains :

- a file parser that embedds some text fileds in vectors
- an elasticsearch ingest pipeline that process additionnel transformations on other numerical/date fields

I’d like to use Knn for a classification use case. i.e. computing the similarity score of each embedded vector against a set of labelised vectors and adding a label to this vector.

Is it possible to do this using some script processor in ingest pipeline ?

---

<div class="post-metadata">

**Author:** ![Vijay](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay](https://forum.opensearch.org/u/Vijay)\
**Post date:** [January 22, 2021, 1:01am UTC](https://forum.opensearch.org/t/compute-similarty-score-while-ingesting-data/4575/2 "2021-01-22T01:01:23Z")

</div>

@wassim.dhib apologies for responding late. I believe script processor is used to perform an operation on individual document like add fields, replace score, etc. from same index.  
In your case, I will build another pipeline as , for every document which contains embedded vector, i will use those vector as query vector for search query on index containing labelised vectors , calculate the label from the search result and update document with label.
