# ( Multimatch && Term ) in should

**URL:** <https://discuss.elastic.co/t/multimatch-term-in-should/14325>\
**Category:** Elasticsearch\
**Created:** [November 8, 2013, 4:41pm UTC](https://discuss.elastic.co/t/multimatch-term-in-should/14325 "2013-11-08T16:41:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![apl](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@apl](https://discuss.elastic.co/u/apl)\
**Post date:** [November 8, 2013, 4:41pm UTC](https://discuss.elastic.co/t/multimatch-term-in-should/14325/1 "2013-11-08T16:41:14Z")

</div>

Hello,

I begin in ElasticSearch 0.9 and I try to make a query including a  
multi\_match and search term in should.

I have many post with content, title, tags and ( author or creator).

I want search all post for an user for a word.

"should":  
{  
"multi\_match": {  
"query": "test",  
"type": "phrase",  
"slop": 4,  
"fields": [  
"title",  
"content",  
"tags"  
] }  
}

If the search find a comment with "test", authorId must be the id in param.  
But it can't be in must node sibling of this should.  
The AND operator must be in the should.

In SQL it's like that :  
WHERE group = 1  
AND  
(  
title LIKE "%test%"  
OR  
content LIKE "%test%"  
OR  
tags LIKE "%test%"  
)  
AND  
(  
authorId = 1  
OR  
creatorId = 1  
)

group = 1 it's in the MUST  
the other in SHOULD

How can I do ?

Best regards

Aurelien

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 8, 2013, 5:23pm UTC](https://discuss.elastic.co/t/multimatch-term-in-should/14325/2 "2013-11-08T17:23:18Z")

</div>

Hi there,

I wrote a gist here. I think it's somehow what you are looking for: [https://gist.github.com/dadoonet/7374452](https://gist.github.com/dadoonet/7374452)

Hope this helps

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

8 novembre 2013 at 17:41:17, [apl@bluekiwi-software.com](mailto:apl@bluekiwi-software.com) ([apl@bluekiwi-software.com](mailto:apl@bluekiwi-software.com)) a écrit:

Hello,

I begin in ElasticSearch 0.9 and I try to make a query including a multi\_match and search term in should.

I have many post with content, title, tags and ( author or creator).

I want search all post for an user for a word.

"should":  
{  
"multi\_match": {  
"query": "test",  
"type": "phrase",  
"slop": 4,  
"fields": [  
"title",  
"content",  
"tags"  
] }  
}

If the search find a comment with "test", authorId must be the id in param. But it can't be in must node sibling of this should.  
The AND operator must be in the should.

In SQL it's like that :  
WHERE group = 1  
AND  
(  
title LIKE "%test%"  
OR  
content LIKE "%test%"  
OR  
tags LIKE "%test%"  
)  
AND  
(  
authorId = 1  
OR  
creatorId = 1  
)

group = 1 it's in the MUST  
the other in SHOULD

How can I do ?

Best regards

## Aurelien

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:** ![apl](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@apl](https://discuss.elastic.co/u/apl)\
**Post date:** [November 12, 2013, 9:01am UTC](https://discuss.elastic.co/t/multimatch-term-in-should/14325/3 "2013-11-12T09:01:42Z")

</div>

Thank you for your help.

Your response has open my mind about possibilities with ES query including  
AND and OR =)  
You have resolved lot of questions about this for me.

Aurelien

On Friday, November 8, 2013 6:23:18 PM UTC+1, David Pilato wrote:

> Hi there,
> 
> I wrote a gist here. I think it's somehow what you are looking for:  
> [Bluekiwi example · GitHub](https://gist.github.com/dadoonet/7374452)
> 
> Hope this helps
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> 8 novembre 2013 at 17:41:17, [a...@bluekiwi-software.com](mailto:a...@bluekiwi-software.com) \<javascript:\> (  
> [a...@bluekiwi-software.com](mailto:a...@bluekiwi-software.com) \<javascript:\>) a écrit:
> 
> Hello,
> 
> I begin in Elasticsearch 0.9 and I try to make a query including a  
> multi\_match and search term in should.
> 
> I have many post with content, title, tags and ( author or creator).
> 
> I want search all post for an user for a word.
> 
> "should":  
> {  
> "multi\_match": {  
> "query": "test",  
> "type": "phrase",  
> "slop": 4,  
> "fields": [  
> "title",  
> "content",  
> "tags"  
> ] }  
> }
> 
> If the search find a comment with "test", authorId must be the id in  
> param. But it can't be in must node sibling of this should.  
> The AND operator must be in the should.
> 
> In SQL it's like that :  
> WHERE group = 1  
> AND  
> (  
> title LIKE "%test%"  
> OR  
> content LIKE "%test%"  
> OR  
> tags LIKE "%test%"  
> )  
> AND  
> (  
> authorId = 1  
> OR  
> creatorId = 1  
> )
> 
> group = 1 it's in the MUST  
> the other in SHOULD
> 
> How can I do ?
> 
> Best regards
> 
> ## Aurelien
> 
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> 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:** ![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:07am UTC](https://discuss.elastic.co/t/multimatch-term-in-should/14325/4 "2017-07-06T02:07:44Z")

</div>


