# Match query vs query string

**URL:** <https://discuss.elastic.co/t/match-query-vs-query-string/15394>\
**Category:** Elasticsearch\
**Created:** [January 24, 2014, 6:02am UTC](https://discuss.elastic.co/t/match-query-vs-query-string/15394 "2014-01-24T06:02:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [January 24, 2014, 6:02am UTC](https://discuss.elastic.co/t/match-query-vs-query-string/15394/1 "2014-01-24T06:02:53Z")

</div>

Hi ,

I am testing the below two queries but it gives different results

_Query 1:_  
......./university/\_search?q=name:Massachusetts%20Insti&fields=name

_Query 2:_  
{"size": 10,  
"fields": [  
"name"  
],  
"query": {  
"match": {  
"name": {  
"query": "Massachusetts Insti"  
}  
}  
}

I believe space between the words is causing problem , how to represent the  
query string in _Query 2_ in\* Query 1 \*i tries "+: "%20" for representing  
spaces.

Regards  
Avinash

--  
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/df824353-2a8a-4bb9-82b8-ac377f78fdc8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/df824353-2a8a-4bb9-82b8-ac377f78fdc8%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Johan\_Rask](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johan_rask/32/1132_2.png) [@Johan\_Rask](https://discuss.elastic.co/u/Johan_Rask)\
**Post date:** [January 24, 2014, 8:19am UTC](https://discuss.elastic.co/t/match-query-vs-query-string/15394/2 "2014-01-24T08:19:19Z")

</div>

Hi,

You have to supply the name of the field for both words.

name:Massachusetts name:Insti , Otherwise it will search for Insti in your  
defaul search field.

....../university/\_search?q=name:Massachusetts%20name:Insti&fields=name

The match query does this for you.

Regards /Johan

Den fredagen den 24:e januari 2014 kl. 07:02:53 UTC+1 skrev paul:

> Hi ,
> 
> I am testing the below two queries but it gives different results
> 
> _Query 1:_  
> ......./university/\_search?q=name:Massachusetts%20Insti&fields=name
> 
> _Query 2:_  
> {"size": 10,  
> "fields": [  
> "name"  
> ],  
> "query": {  
> "match": {  
> "name": {  
> "query": "Massachusetts Insti"  
> }  
> }  
> }
> 
> I believe space between the words is causing problem , how to represent  
> the query string in _Query 2_ in\* Query 1 \*i tries "+: "%20" for  
> representing spaces.
> 
> Regards  
> Avinash

--  
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/1388fcd8-b188-44d4-acd5-925175b46849%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1388fcd8-b188-44d4-acd5-925175b46849%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [January 26, 2014, 8:04am UTC](https://discuss.elastic.co/t/match-query-vs-query-string/15394/3 "2014-01-26T08:04:47Z")

</div>

thank Johan you will try it.

-paul

On Fri, Jan 24, 2014 at 1:49 PM, Johan Rask [johan.rask@jayway.com](mailto:johan.rask@jayway.com) wrote:

> Hi,
> 
> You have to supply the name of the field for both words.
> 
> name:Massachusetts name:Insti , Otherwise it will search for Insti in your  
> defaul search field.
> 
> ....../university/\_search?q=name:Massachusetts%20name:Insti&fields=name
> 
> The match query does this for you.
> 
> Regards /Johan
> 
> Den fredagen den 24:e januari 2014 kl. 07:02:53 UTC+1 skrev paul:
> 
> > Hi ,
> > 
> > I am testing the below two queries but it gives different results
> > 
> > _Query 1:_  
> > ......./university/\_search?q=name:Massachusetts%20Insti&fields=name
> > 
> > _Query 2:_  
> > {"size": 10,  
> > "fields": [  
> > "name"  
> > ],  
> > "query": {  
> > "match": {  
> > "name": {  
> > "query": "Massachusetts Insti"  
> > }  
> > }  
> > }
> > 
> > I believe space between the words is causing problem , how to represent  
> > the query string in _Query 2_ in\* Query 1 \*i tries "+: "%20" for  
> > representing spaces.
> > 
> > Regards  
> > Avinash
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/Lx083-eHwoM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/Lx083-eHwoM/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/1388fcd8-b188-44d4-acd5-925175b46849%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1388fcd8-b188-44d4-acd5-925175b46849%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAO066G1jz6UFpZO1OvkGQtMx8tp7ij-FB4F18wkXciCoZ8OG1g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAO066G1jz6UFpZO1OvkGQtMx8tp7ij-FB4F18wkXciCoZ8OG1g%40mail.gmail.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, 1:54am UTC](https://discuss.elastic.co/t/match-query-vs-query-string/15394/4 "2017-07-06T01:54:45Z")

</div>


