# Need Exact Search on Two Fields

**URL:** <https://discuss.elastic.co/t/need-exact-search-on-two-fields/16553>\
**Category:** Elasticsearch\
**Created:** [March 23, 2014, 10:31pm UTC](https://discuss.elastic.co/t/need-exact-search-on-two-fields/16553 "2014-03-23T22:31:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randy\_Jensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/randy_jensen/32/1279_2.png) [@Randy\_Jensen](https://discuss.elastic.co/u/Randy_Jensen)\
**Post date:** [March 23, 2014, 10:31pm UTC](https://discuss.elastic.co/t/need-exact-search-on-two-fields/16553/1 "2014-03-23T22:31:31Z")

</div>

I need to be able to do an exact search against two fields, Program Heading  
and Subheading each with it's own search term.

For example, I might need to search for Health Professions -\> Medical. So  
the Program Area field would be "Health Professions" and the Subheading  
field would be "Medical". Again, I need exact searched, so "Medical  
Marketing" wouldn't come back as a Subheading if "Medical" is searched for  
or if Medical appears as a subheading under another Program Area.

I've tried every variation of every query I can think of and can't get it  
exactly right. I have the mapping below:

'properties' =\> array(  
'program\_area' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'program\_area' =\> array(  
'type' =\> 'string',  
'index' =\> 'analyzed'  
),  
'program\_area\_raw' =\> array(  
'type' =\> 'string',  
'index' =\> 'not\_analyzed',  
'store' =\> true  
)  
)  
),  
'subheading' =\> array(  
'type' =\> 'multi\_field',  
'fields' =\> array(  
'subheading' =\> array(  
'type' =\> 'string',  
'index' =\> 'analyzed',  
'store' =\> true  
),  
'subheading\_raw' =\> array(  
'type' =\> 'string',  
'index' =\> 'not\_analyzed',  
'store' =\> true  
)  
)  
),  
)

--  
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/705e6394-1edc-4236-bbf1-a4f6b22f0eb9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/705e6394-1edc-4236-bbf1-a4f6b22f0eb9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 24, 2014, 4:17pm UTC](https://discuss.elastic.co/t/need-exact-search-on-two-fields/16553/2 "2014-03-24T16:17:04Z")

</div>

What happens if you try searching only on the \_raw fields, like for example:

{  
"query": {  
"filtered": {  
"filter": {  
"bool": {  
"must": [  
{  
"term": { "program\_area\_raw": "Health Professions" }  
},  
{  
"term": { "subheading\_raw": "Medical" }  
}  
]  
}  
}  
}  
}  
}

--  
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/ac2398bb-bd53-4e1e-b0a3-8b7fc0bf2b49%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ac2398bb-bd53-4e1e-b0a3-8b7fc0bf2b49%40googlegroups.com).  
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, 1:41am UTC](https://discuss.elastic.co/t/need-exact-search-on-two-fields/16553/3 "2017-07-06T01:41:06Z")

</div>

Closed on July 6, 2017, 1:41am UTC


