Help needed, addressbook search, one to many relation

I have following use case:
A person have multiple addresses. The search should return most relevant people.
I need to show best match which is result that matched most number of search fields and close matches which are result of the results sorted by score. I should also drop results matched only one field.

		"name": "Jon",
		"hobby": ["games", "food"],
		"addresses": [
			{"city": "London", "title": "Developer", "company": "Apple"},
			{"city": "New York", "title": "Lead", "company": "Google"},
		"name": "Gabe",
		"hobby": ["movie", "food"],
		"addresses": [
			{"city": "Chicago", "title": "CTO", "company": "Red baloon"},
			{"city": "Indiana", "title": "Manager", "company": "XYZ"},

Apple lead London => Best match Gabe, other match: Jon
Red baloon => Best match Gabe 

How do I achieve this?


Thank you for reaching out !
So what you could do is play with the order of your attributes in “Searchable Attribute”, tab Ranking, in your index’s dashboard.
You could have “name” in first position, and then, addresses.title,, depending on the order of importance you want.
For instance, in that order, you would get Jon for “Apple lead London” and Gabe for “Red baloon”. Btw, you cannot have “Apple lead London => Best match Gabe, other match: Jon”, since Gabe does not have any of the following keywords.

Let me know, if this help

Thank you. Yes, I understand ranking part of it. How about the other requirement where I could define that the results must have x number of fields matched and the fields they matched on.