I have a user profile with some fields like:
- username
- gender
- nationality
- age
- language
- preferred language
- preferred age
Each user should be able to search other users based on some filters (username, gender, age, language) and the final result should be sorted by a score based on preferences (preferred language, preferred age)
Consider this example:
User profile:
- username = 'randomdude'
- gender = 'male'
- nationality = 'italian'
- age = '21'
- language = 'english,italian,spanish'
- preferred language = 'english,italian'
- preferred age = '20-30'
Randomdude wants to make a research on our ElasticSearch documents and he would set these filters:
- gender = 'female'
- nationality = 'spanish'
So the final list should contain ONLY SPANISH FEMALES but it should prefer people with ENGLISH or ITALIAN in the language field and age between 20 and 30, without excluding the rest. So he still can see people that talk in spanish and have 40, but almost at the end of the list.
I'm using the Elasticsearch's php wrapper. I tried using a lot of functions and I think I should use the function score query but I can't make it work because the documentation is very confusing for me.