# Multi-field query syntax

**URL:** <https://discuss.elastic.co/t/multi-field-query-syntax/12812>\
**Category:** Elasticsearch\
**Created:** [July 16, 2013, 8:11pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812 "2013-07-16T20:11:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hassan\_Schroeder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hassan_schroeder/32/1526_2.png) [@Hassan\_Schroeder](https://discuss.elastic.co/u/Hassan_Schroeder)\
**Post date:** [July 16, 2013, 8:11pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/1 "2013-07-16T20:11:42Z")

</div>

I'm struggling with ES syntax right now. Is there a way to match  
e.g. term A against field A and term B against field B in a simple  
boolean query?

The gist below "works" as in "returns the appropriate entries" using  
sense as the client (despite sense complaining about the duplicate  
"must") - but it doesn't feel right and it's not DRY.

> <https://gist.github.com/hassan/16e48838886109c4b2bb>

What's the proper way to do this?

TIA!

## H\*

Hassan Schroeder ------------------------ [hassan.schroeder@gmail.com](mailto:hassan.schroeder@gmail.com)  
[http://about.me/hassanschroeder](http://about.me/hassanschroeder)  
twitter: @hassan

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 17, 2013, 6:19am UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/2 "2013-07-17T06:19:15Z")

</div>

Hey,

good if it works! In order to improve slightly you could make the must  
field an array which contains your queries.

--Alex

On Tue, Jul 16, 2013 at 10:11 PM, Hassan Schroeder \<  
[hassan.schroeder@gmail.com](mailto:hassan.schroeder@gmail.com)\> wrote:

> I'm struggling with ES syntax right now. Is there a way to match  
> e.g. term A against field A and term B against field B in a simple  
> boolean query?
> 
> The gist below "works" as in "returns the appropriate entries" using  
> sense as the client (despite sense complaining about the duplicate  
> "must") - but it doesn't feel right and it's not DRY.
> 
> [elasticsearch query syntax - not DRY enough · GitHub](https://gist.github.com/hassan/16e48838886109c4b2bb)
> 
> What's the proper way to do this?
> 
> TIA!
> 
> ## H\*
> 
> Hassan Schroeder ------------------------ [hassan.schroeder@gmail.com](mailto:hassan.schroeder@gmail.com)  
> [Hassan Schroeder | about.me](http://about.me/hassanschroeder)  
> twitter: @hassan
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Hassan\_Schroeder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hassan_schroeder/32/1526_2.png) [@Hassan\_Schroeder](https://discuss.elastic.co/u/Hassan_Schroeder)\
**Post date:** [July 17, 2013, 12:09pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/3 "2013-07-17T12:09:52Z")

</div>

On Tue, Jul 16, 2013 at 11:19 PM, Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de) wrote:

> good if it works! In order to improve slightly you could make the must field  
> an array which contains your queries.

Uh, yeah, that's what I'd like to do -- but what does that look like?  
I thought I understood JSON format but NOTHING I can come up  
with results in anything but errors like

QueryParsingException[[resources] [match] query malformed, no field]

A working example would be extremely helpful (and a good thing to  
add to the docs, I'd think).

I'm using ES 0.90.0, BTW, in case this is a known problem.

## TIA,

Hassan Schroeder ------------------------ [hassan.schroeder@gmail.com](mailto:hassan.schroeder@gmail.com)  
[Hassan Schroeder | about.me](http://about.me/hassanschroeder)  
twitter: @hassan

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Christian\_Th](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Christian\_Th](https://discuss.elastic.co/u/Christian_Th)\
**Post date:** [July 17, 2013, 12:23pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/4 "2013-07-17T12:23:37Z")

</div>

I recommend to use suche plugin- GUIs like  
[http://mobz.github.io/elasticsearch-head/](http://mobz.github.io/elasticsearch-head/)

> **[jettro/elasticsearch-gui](https://github.com/jettro/elasticsearch-gui)**
>
> elasticsearch-gui - An angularJS client for elasticsearch as a plugin

  
or an other gui like  

> **[okfn/facetview](https://github.com/okfn/facetview)**
>
> facetview - FacetView is a pure javascript frontend for ElasticSearch.

With Chrome, FireFox,.. you can take a look at the generated JSON.

Hope this helps

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Christian\_Th](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Christian\_Th](https://discuss.elastic.co/u/Christian_Th)\
**Post date:** [July 17, 2013, 12:24pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/5 "2013-07-17T12:24:02Z")

</div>

I recommend to use such plugin- GUIs like  
[http://mobz.github.io/elasticsearch-head/](http://mobz.github.io/elasticsearch-head/)

> **[jettro/elasticsearch-gui](https://github.com/jettro/elasticsearch-gui)**
>
> elasticsearch-gui - An angularJS client for elasticsearch as a plugin

  
or an other gui like  

> **[okfn/facetview](https://github.com/okfn/facetview)**
>
> facetview - FacetView is a pure javascript frontend for ElasticSearch.

With Chrome, FireFox,.. you can take a look at the generated JSON.

Hope this helps

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Hassan\_Schroeder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hassan_schroeder/32/1526_2.png) [@Hassan\_Schroeder](https://discuss.elastic.co/u/Hassan_Schroeder)\
**Post date:** [July 17, 2013, 1:04pm UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/6 "2013-07-17T13:04:21Z")

</div>

On Wed, Jul 17, 2013 at 5:24 AM, Christian Th. [chth.exensio@gmail.com](mailto:chth.exensio@gmail.com) wrote:

> I recommend to use such plugin- GUIs like  
> [ElasticSearch Head](http://mobz.github.io/elasticsearch-head/)  
> [GitHub - jettro/elasticsearch-gui: An angularJS client for elasticsearch as a plugin](https://github.com/jettro/elasticsearch-gui)  
> or an other gui like  
> [GitHub - rufuspollock-okfn/facetview: FacetView is a pure javascript frontend for ElasticSearch.](https://github.com/okfn/facetview)
> 
> With Chrome, FireFox,.. you can take a look at the generated JSON.
> 
> Hope this helps

Thank you, yes -- seeing some generated queries shed light on  
my issue (which wasn't actually json-format-related), though now  
I apparently need to go back to the docs for a little more study 🙂

Thanks again,

## H\*

Hassan Schroeder ------------------------ [hassan.schroeder@gmail.com](mailto:hassan.schroeder@gmail.com)  
[Hassan Schroeder | about.me](http://about.me/hassanschroeder)  
twitter: @hassan

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:25am UTC](https://discuss.elastic.co/t/multi-field-query-syntax/12812/7 "2017-07-06T02:25:57Z")

</div>


