I'm using Elasticsearch v 1.7.3
Here are my fields in the document:
Field1, Field2, Field3, Field4
I need to give the weightage to each field say Field1: 40, Field2: 40, Field3: 10, Field4: 10
During indexing, Field1 and Field2 are expanded to their phonetic tokens. So we have Field1 ==> Field1, Field1.1, Field1.2 and Field2 => Field2, Field2.1, Field2.2
My query can be based on a combination of any of the above 4 fields.
Now for scoring, I don't want to use TF/IDF or BM25 scoring models.
Rather I simply want to compute the weighted average per field and sum them together.
For example for input query:
Field1: ABC
Field2: PQR
Field3: XYZ
Field4: RST
Assume there are the following documents in the corpus:
Document 1
-----------
Field1: ABC
Field2: PQR
Field3: XYZ
Field4: RST
Document 2
-----------
Field1: ABX
Field2: PQR
Field3: XYZ
Field4: RST
Score for Document 1: 100 ==> WeightedAverage(Field1) + WeightedAverage(Field2) + WeightedAverage(Field3) + WeightedAverage(Field4) ===> 40 + 40 + 10 + 10
Score for Document 2: 90 ==> WeightedAverage(Field1) + WeightedAverage(Field2) + WeightedAverage(Field3) + WeightedAverage(Field4) ===> 30 + 40 + 10 + 10 (Not exactly but I hope you get the idea).
Can I do this in function_score query? I couldn't quite get how this can be accomplished. Thanks.