Matching documents against each other on specified properties instead of a search term

Instead of searching for a query, Is there a way of comparing documents
against one another?

For example, let's imagine a domain where each member has a 'profile'
Each profile has many key:value pairs, like:

favourite_color: "Blue"
favourite_food: "Pizza"
favourite_place: "Beach"

Further document structure example:

id: 1
name: John Smith
favourite_color: Blue
favourite_food: Pizza
other_value: Some Value

id: 2
name: Sarah Jones
favourite_color: Green
favourite_food: Chinese
birthday_month: June
other_value: Whatever

id: 3
name: Andy Green
favourite_color: Blue
favourite_food: Pizza
other_value: Other Value
birthday_month: June

id: 4
name: Simon
favourite_color: Blue
favourite_food: Pizza
other_value: Other Value
birthday_month: May

I'd like to be able to pass in a query such as:

"return all the documents where favourite_colour and favourite_place match"

In the above example, 1, 3 and 4 would be returned.

another query may be:

"return all the documents where favourite_colour and favourite_place match
BUT where other_value DO NOT match"
In the above example, 1 and 3 would be returned. 4 would not, since
other_value matches with 3

Is that possible with ElasticSearch?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.