# Match all fields except one

**URL:** <https://discuss.elastic.co/t/match-all-fields-except-one/491>\
**Category:** Elasticsearch\
**Created:** [May 11, 2015, 11:25am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491 "2015-05-11T11:25:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![flarpy](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@flarpy](https://discuss.elastic.co/u/flarpy)\
**Post date:** [May 11, 2015, 11:25am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/1 "2015-05-11T11:25:58Z")

</div>

Hi

I have a collection of products, all with different attributes. I want to do a search on all attributes EXCEPT name, what is the easiest way to do this?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Joshua\_Rich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshua_rich/32/44953_2.png) [@Joshua\_Rich](https://discuss.elastic.co/u/Joshua_Rich)\
**Post date:** [May 12, 2015, 6:38am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/2 "2015-05-12T06:38:46Z")

</div>

In your field mapping, you can specify `"index": "no"` for the `name` field which will result in that field not being searchable at all, for all searches. If you just need to disable searching on that field for this particular search, you've really got no option but to use a _multi\_match_ query and explicitly list all the fields except the `name` field.

---

<div class="post-metadata">

**Author:** ![flarpy](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@flarpy](https://discuss.elastic.co/u/flarpy)\
**Post date:** [May 12, 2015, 8:00am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/3 "2015-05-12T08:00:01Z")

</div>

Thanks for your response.

How about if I have 2 indexes, one with all fields, one with all except name. Then I can specify a different index at search time, could that work?

---

<div class="post-metadata">

**Author:** ![Camilo\_Sierra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/camilo_sierra/32/14397_2.png) [@Camilo\_Sierra](https://discuss.elastic.co/u/Camilo_Sierra)\
**Post date:** [May 12, 2015, 8:44am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/4 "2015-05-12T08:44:07Z")

</div>

they are multiple possibilities, as you say you can duplicate your data or for use less disk space and memory you can create one index with all except name, and for the second one you can index only the name,  
For the query use \*multiple indices if you search in both indexes data + name or search only in the first index (all data except the name) if you need search only n your data...  
or even better as say @Joshua_Rich use the multi\_match query !

- [http://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html](http://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html)

---

<div class="post-metadata">

**Author:** ![flarpy](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@flarpy](https://discuss.elastic.co/u/flarpy)\
**Post date:** [May 12, 2015, 4:22pm UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/5 "2015-05-12T16:22:05Z")

</div>

I will try the 2 index approach first, thanks for your help

---

<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:14am UTC](https://discuss.elastic.co/t/match-all-fields-except-one/491/6 "2017-07-06T00:14:26Z")

</div>


