# Field comparision

**URL:** <https://discuss.elastic.co/t/field-comparision/22709>\
**Category:** Elasticsearch\
**Created:** [March 17, 2015, 1:12pm UTC](https://discuss.elastic.co/t/field-comparision/22709 "2015-03-17T13:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanbnv](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pavanbnv](https://discuss.elastic.co/u/pavanbnv)\
**Post date:** [March 17, 2015, 1:12pm UTC](https://discuss.elastic.co/t/field-comparision/22709/1 "2015-03-17T13:12:37Z")

</div>

Hi all,

Is there any way to achieve field comparison.

If I index a type  
{  
manager : ,  
teamMember :   
}

how to write a query when a manager is also a teamMember ?

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/92ac7c28-3810-4b94-820c-0005c086f176%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92ac7c28-3810-4b94-820c-0005c086f176%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![masaru](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@masaru](https://discuss.elastic.co/u/masaru)\
**Post date:** [March 20, 2015, 1:50am UTC](https://discuss.elastic.co/t/field-comparision/22709/2 "2015-03-20T01:50:52Z")

</div>

Hi,

You can use script filter([Script query | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html)).  
Checking doc['manager'].value == doc['teamMember'].value should work.

Alternatively, you can precompute it and add managerIsAlsoTeamMember field to documents.

Masaru

On March 17, 2015 at 22:12:42, Pavan Kumar ([pavan.bnv@gmail.com](mailto:pavan.bnv@gmail.com)) wrote:

> Hi all,
> 
> Is there any way to achieve field comparison.
> 
> If I index a type  
> {  
> manager : ,  
> teamMember :  
> }
> 
> how to write a query when a manager is also a teamMember ?
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/92ac7c28-3810-4b94-820c-0005c086f176%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/92ac7c28-3810-4b94-820c-0005c086f176%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.550b7d38.6b8b4567.166%40citra-2.local](https://groups.google.com/d/msgid/elasticsearch/etPan.550b7d38.6b8b4567.166%40citra-2.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:25am UTC](https://discuss.elastic.co/t/field-comparision/22709/3 "2017-07-06T00:25:26Z")

</div>


