Hello I am finding a solution to achieve a scenario where an index having suppose 10 records each record having last name, first name and phone number etc fields and I want to do partial match and exact match for these fields and also modify the scores of the documents according to how much they match with the given value of these fields. For example, what ever value we give for firstname the documents having partial matching will have less score, documents having exact matching will have more score and two records having exact match will have same score. How can I achieve that ?
Right Now I figured out this process
- In order to do partial match I am going ahead I am using query string. however, tried with other queries as well such as wildcard as well but I think it does not work with text/string values
- To modify the score of each record according to the query I considered 2 solutions
- function_score function
- script_score function
- I am working with script_score function now
- Inside script_score I am using randomScore() function with values passed as 100
- To calculate percentage for every search result we get a max score value
- I will be using this formula to calculate the percentages for each document
percenatge = (score of every record/max score)*100
After all this I am not able to achieve desired scores for each document.