Compare properties

Hi,
i'm quiet new to elasticsearch and i wonder if it is possibile to write a query to get all types where type1.name = typ2.name?

Any hints about that?

You could use a script filter but this would be very slow as script filters cannot leverage the inverted index. For such queries, the best option is to pre-compute this kind of information at indexing time ("is_type1_equal_to_type2": true) so that you can later use simple term queries to find documents you are interested in.

I suspect its possible to do much better by implementing a new query as a
plugin. It'd parallel walk the terms dictionary. But Elasticsearch doesn't
have a query for that already implemented and exposed.

The script approach is best if you aren't going to do it much. The
precomputed approach for when you only have a couple of these fields and
are willing to reindex. I'd go with a flags style field, not_analyzed with
array of flags for the fields that are the same.

The new query way is much more to learn and code but could be more flexible
if you have lots of fields.

You could use all three methods to handle stuff like _source.a == _source.b + 10.

Finding too documents with the same value in a field pairwise would be much
much harder.
Nik