# Es multi\_match problem

**URL:** <https://discuss.elastic.co/t/es-multi-match-problem/10445>\
**Category:** Elasticsearch\
**Created:** [January 21, 2013, 11:32pm UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445 "2013-01-21T23:32:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sulemanmubarik](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sulemanmubarik](https://discuss.elastic.co/u/sulemanmubarik)\
**Post date:** [January 21, 2013, 11:32pm UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/1 "2013-01-21T23:32:16Z")

</div>

Hi I have this search query (Ford in Detroit)

It is evaluating as (Ford AND in AND Detroit)

When I apply the stop word filter (analyzer) it become (Ford AND AND  
Detroit)

When I run this

Here is the JSON which ES is evaluating

{ "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
"must" : [ { "multi\_match" : { "query" : "in", "fields" : [ "authorName",  
"authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
"operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : { "query"  
: "Detroit", "fields" : [ "authorName", "authorTags", "cnt\_en",  
"permalink", "t\_en" ], "type" : "boolean", "operator" : "AND",  
"use\_dis\_max" : false } }, { "multi\_match" : { "query" : "Ford", "fields" :  
["authorName", "authorTags", "cnt\_en", "permalink", "t\_en"], "type" :  
"boolean", "operator" : "AND", "use\_dis\_max" : false } } ] } }, "boost" :  
1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : { "filters" : [ {  
"term" : { "authorCountry" : "United States", "\_cache" : false } } ] } }, {  
"or" : { "filters" : [ { "term" : { "authorLanguage" : 12, "\_cache" : false  
} } ] } }, { "numeric\_range" : { "publishedDate" : { "from" :  
1355616000000, "to" : 1358467199999, "include\_lower" : true,  
"include\_upper" : true } } } ] } } } }

Is there a way so the ES analyzer remove the multi\_match when it find the  
stop word and in that case my search term will become (Ford AND Detroit)

or any idea how can i remove this

Thanks

--

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [January 22, 2013, 12:06am UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/2 "2013-01-22T00:06:34Z")

</div>

multi\_match is analyzed so you don't need to wrap each term inside the  
boolean query. Why don't you use a single multi\_match, set the query to  
"Ford in Detroit" and operator to AND? By doing this, your "in" will be  
removed due to stopwords and your query will turn into "Ford AND Detroit"  
as you want. Also, you can use TermsFilter vs. wrapping in an OR filter.  
Here is your query using the Elastic.js javascript DSL:

ejs.Request()  
.query(  
ejs.FilteredQuery(

ejs.MultiMatchQuery(["authorName","authorTags","cnt\_en","permalink","t\_en"],  
"Ford in Detroit")  
.operator('and')  
.useDisMax(false),  
ejs.AndFilter([  
ejs.TermsFilter('authorCountry', ['United States'])  
.cache(false),  
ejs.TermsFilter('authorLanguage', [12])  
.cache(false),  
ejs.NumericRangeFilter('publishedDate')  
.from(1355616000000)  
.to(1358467199999)  
.includeLower(true)  
.includeUpper(true)  
])));

Use the FullScale Labs translator to generate the full JSON:

[http://docs.fullscale.co/translator/](http://docs.fullscale.co/translator/)

Thanks,  
Matt Weber

On Mon, Jan 21, 2013 at 3:32 PM, suleman mubarik  
[sulemanmubarik@gmail.com](mailto:sulemanmubarik@gmail.com)wrote:

> Hi I have this search query (Ford in Detroit)
> 
> It is evaluating as (Ford AND in AND Detroit)
> 
> When I apply the stop word filter (analyzer) it become (Ford AND AND  
> Detroit)
> 
> When I run this
> 
> Here is the JSON which ES is evaluating
> 
> { "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
> "must" : [ { "multi\_match" : { "query" : "in", "fields" : [ "authorName",  
> "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
> "operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : {  
> "query" : "Detroit", "fields" : [ "authorName", "authorTags", "cnt\_en",  
> "permalink", "t\_en" ], "type" : "boolean", "operator" : "AND",  
> "use\_dis\_max" : false } }, { "multi\_match" : { "query" : "Ford", "fields" :  
> ["authorName", "authorTags", "cnt\_en", "permalink", "t\_en"], "type" :  
> "boolean", "operator" : "AND", "use\_dis\_max" : false } } ] } }, "boost" :  
> 1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : { "filters" : [ {  
> "term" : { "authorCountry" : "United States", "\_cache" : false } } ] } }, {  
> "or" : { "filters" : [ { "term" : { "authorLanguage" : 12, "\_cache" : false  
> } } ] } }, { "numeric\_range" : { "publishedDate" : { "from" :  
> 1355616000000, "to" : 1358467199999, "include\_lower" : true,  
> "include\_upper" : true } } } ] } } } }
> 
> Is there a way so the ES analyzer remove the multi\_match when it find the  
> stop word and in that case my search term will become (Ford AND Detroit)
> 
> or any idea how can i remove this
> 
> Thanks
> 
> --

--

---

<div class="post-metadata">

**Author:** ![sulemanmubarik](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sulemanmubarik](https://discuss.elastic.co/u/sulemanmubarik)\
**Post date:** [January 22, 2013, 11:55pm UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/3 "2013-01-22T23:55:43Z")

</div>

Thanks Matt

I am treating "Ford in Detroit" as a phrase and it is working fine for me  
and I am getting correct results

But when I search Ford in Detroit I am doing a multi single word search  
i.e. I am searching for Ford AND Detroit after removing the stop words .  
Ford and Detroit can be in any place in text

But ES does not convert (Ford AND in AND Detroit) to (Ford AND Detroit)  
after applying stop words

So I need when ES see Ford in Detroit it should treat it as Ford Detroit

Here is the json when I send "Ford in Detroit" , (Ford Detroit) or (Ford in  
Detroit)

When "Ford in Detroit"

{

```
"filtered": {

    "query": {

        "constant_score": {

            "query": {

                "multi_match": {

                    "query": "Ford in Detroit",

                    "fields": [

                        "authorName",

                        "authorTags",

                        "cnt_en",

                        "permalink",

                        "t_en"

                    ],

                    "type": "phrase",

                    "operator": "AND",

                    "use_dis_max": false

                }

            },

            "boost": 1

        }

    },

    "filter": {

        "and": {

            "filters": [

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorCountry": "United States",

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorLanguage": 12,

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "numeric_range": {

                        "publishedDate": {

                            "from": 1356220800000,

                            "to": 1358985600000,

                            "include_lower": true,

                            "include_upper": true

                        }

                    }

                }

            ]

        }

    }

}

```

}

When Ford Detroit

{

```
"filtered": {

    "query": {

        "constant_score": {

            "query": {

                "bool": {

                    "must": [

                        {

                            "multi_match": {

                                "query": "Detroit",

                                "fields": [

                                    "authorName",

                                    "authorTags",

                                    "cnt_en",

                                    "permalink",

                                    "t_en"

                                ],

                                "type": "boolean",

                                "operator": "AND",

                                "use_dis_max": false

                            }

                        },

                        {

                            "multi_match": {

                                "query": "Ford",

                                "fields": [

                                    "authorName",

                                    "authorTags",

                                    "cnt_en",

                                    "permalink",

                                    "t_en"

                                ],

                                "type": "boolean",

                                "operator": "AND",

                                "use_dis_max": false

                            }

                        }

                    ]

                }

            },

            "boost": 1

        }

    },

    "filter": {

        "and": {

            "filters": [

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorCountry": "United States",

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorLanguage": 12,

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "numeric_range": {

                        "publishedDate": {

                            "from": 1356220800000,

                            "to": 1358985600000,

                            "include_lower": true,

                            "include_upper": true

                        }

                    }

                }

            ]

        }

    }

}

```

}

When Ford in Detroit

{

```
"filtered": {

    "query": {

        "constant_score": {

            "query": {

                "bool": {

                    "must": [

                        {

                            "multi_match": {

                                "query": "in",

                                "fields": [

                                    "authorName",

                                    "authorTags",

                                    "cnt_en",

                                    "permalink",

                                    "t_en"

                                ],

                                "type": "boolean",

                                "operator": "AND",

                                "use_dis_max": false

                            }

                        },

                        {

                            "multi_match": {

                                "query": "Detroit",

                                "fields": [

                                    "authorName",

                                    "authorTags",

                                    "cnt_en",

                                    "permalink",

                                    "t_en"

                                ],

                                "type": "boolean",

                                "operator": "AND",

                                "use_dis_max": false

                            }

                        },

                        {

                            "multi_match": {

                                "query": "Ford",

                                "fields": [

                                    "authorName",

                                    "authorTags",

                                    "cnt_en",

                                    "permalink",

                                    "t_en"

                                ],

                                "type": "boolean",

                                "operator": "AND",

                                "use_dis_max": false

                            }

                        }

                    ]

                }

            },

            "boost": 1

        }

    },

    "filter": {

        "and": {

            "filters": [

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorCountry": "United States",

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "or": {

                        "filters": [

                            {

                                "term": {

                                    "authorLanguage": 12,

                                    "_cache": false

                                }

                            }

                        ]

                    }

                },

                {

                    "numeric_range": {

                        "publishedDate": {

                            "from": 1356220800000,

                            "to": 1358985600000,

                            "include_lower": true,

                            "include_upper": true

                        }

                    }

                }

            ]

        }

    }

}

```

}

On Monday, January 21, 2013 3:32:16 PM UTC-8, suleman mubarik wrote:

> Hi I have this search query (Ford in Detroit)
> 
> It is evaluating as (Ford AND in AND Detroit)
> 
> When I apply the stop word filter (analyzer) it become (Ford AND AND  
> Detroit)
> 
> When I run this
> 
> Here is the JSON which ES is evaluating
> 
> { "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
> "must" : [ { "multi\_match" : { "query" : "in", "fields" : [ "authorName",  
> "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
> "operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : {  
> "query" : "Detroit", "fields" : [ "authorName", "authorTags", "cnt\_en",  
> "permalink", "t\_en" ], "type" : "boolean", "operator" : "AND",  
> "use\_dis\_max" : false } }, { "multi\_match" : { "query" : "Ford", "fields" :  
> ["authorName", "authorTags", "cnt\_en", "permalink", "t\_en"], "type" :  
> "boolean", "operator" : "AND", "use\_dis\_max" : false } } ] } }, "boost" :  
> 1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : { "filters" : [ {  
> "term" : { "authorCountry" : "United States", "\_cache" : false } } ] } }, {  
> "or" : { "filters" : [ { "term" : { "authorLanguage" : 12, "\_cache" : false  
> } } ] } }, { "numeric\_range" : { "publishedDate" : { "from" :  
> 1355616000000, "to" : 1358467199999, "include\_lower" : true,  
> "include\_upper" : true } } } ] } } } }
> 
> Is there a way so the ES analyzer remove the multi\_match when it find the  
> stop word and in that case my search term will become (Ford AND Detroit)
> 
> or any idea how can i remove this
> 
> Thanks

--

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [January 23, 2013, 12:11am UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/4 "2013-01-23T00:11:13Z")

</div>

Don't craft the Boolean queries yourself, let Elasticsearch do it within  
the match query. Use the translator again...

# "Ford in Detroit", notice type as "phrase"

ejs.Request()  
.query(  
ejs.FilteredQuery(

ejs.MultiMatchQuery(["authorName","authorTags","cnt\_en","permalink","t\_en"],  
"Ford in Detroit")  
.operator('and')  
.useDisMax(false)  
.type('phrase'),  
ejs.AndFilter([  
ejs.TermsFilter('authorCountry', ['United States'])  
.cache(false),  
ejs.TermsFilter('authorLanguage', [12])  
.cache(false),  
ejs.NumericRangeFilter('publishedDate')  
.from(1355616000000)  
.to(1358467199999)  
.includeLower(true)  
.includeUpper(true)  
])));

# Ford Detroit and Ford in Detroit use the same format, notice no type set.

Defaults to boolean.

ejs.Request()  
.query(  
ejs.FilteredQuery(

ejs.MultiMatchQuery(["authorName","authorTags","cnt\_en","permalink","t\_en"],  
"Ford in Detroit")  
.operator('and')  
.useDisMax(false),  
ejs.AndFilter([  
ejs.TermsFilter('authorCountry', ['United States'])  
.cache(false),  
ejs.TermsFilter('authorLanguage', [12])  
.cache(false),  
ejs.NumericRangeFilter('publishedDate')  
.from(1355616000000)  
.to(1358467199999)  
.includeLower(true)  
.includeUpper(true)  
])));

The match query will create the lucene boolean queries for you behind the  
scenes. It tokenizes the the query string the same as the underlying field  
being searched, or you can set one manually. So if you remove stopwords on  
the field, they will be removed from the query string as well. Assuming  
you are using an analyzer that removes stopwords, the match query above is  
the same as "Ford AND Detroit".

Thanks,  
Matt Weber

On Tue, Jan 22, 2013 at 3:55 PM, suleman mubarik  
[sulemanmubarik@gmail.com](mailto:sulemanmubarik@gmail.com)wrote:

> Thanks Matt
> 
> I am treating "Ford in Detroit" as a phrase and it is working fine for me  
> and I am getting correct results
> 
> But when I search Ford in Detroit I am doing a multi single word search  
> i.e. I am searching for Ford AND Detroit after removing the stop words .  
> Ford and Detroit can be in any place in text
> 
> But ES does not convert (Ford AND in AND Detroit) to (Ford AND Detroit)  
> after applying stop words
> 
> So I need when ES see Ford in Detroit it should treat it as Ford Detroit
> 
> Here is the json when I send "Ford in Detroit" , (Ford Detroit) or (Ford  
> in Detroit)
> 
> When "Ford in Detroit"
> 
> {
> 
> ```
> "filtered": {
> 
> "query": {
> 
> "constant_score": {
> 
> "query": {
> 
> "multi_match": {
> 
> "query": "Ford in Detroit",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "phrase",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> },
> 
> "boost": 1
> 
> }
> 
> },
> 
> "filter": {
> 
> "and": {
> 
> "filters": [
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorCountry": "United States",
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorLanguage": 12,
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "numeric_range": {
> 
> "publishedDate": {
> 
> "from": 1356220800000,
> 
> "to": 1358985600000,
> 
> "include_lower": true,
> 
> "include_upper": true
> 
> }
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> When Ford Detroit
> 
> {
> 
> ```
> "filtered": {
> 
> "query": {
> 
> "constant_score": {
> 
> "query": {
> 
> "bool": {
> 
> "must": [
> 
> {
> 
> "multi_match": {
> 
> "query": "Detroit",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "boolean",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> },
> 
> {
> 
> "multi_match": {
> 
> "query": "Ford",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "boolean",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> "boost": 1
> 
> }
> 
> },
> 
> "filter": {
> 
> "and": {
> 
> "filters": [
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorCountry": "United States",
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorLanguage": 12,
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "numeric_range": {
> 
> "publishedDate": {
> 
> "from": 1356220800000,
> 
> "to": 1358985600000,
> 
> "include_lower": true,
> 
> "include_upper": true
> 
> }
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> When Ford in Detroit
> 
> {
> 
> ```
> "filtered": {
> 
> "query": {
> 
> "constant_score": {
> 
> "query": {
> 
> "bool": {
> 
> "must": [
> 
> {
> 
> "multi_match": {
> 
> "query": "in",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "boolean",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> },
> 
> {
> 
> "multi_match": {
> 
> "query": "Detroit",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "boolean",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> },
> 
> {
> 
> "multi_match": {
> 
> "query": "Ford",
> 
> "fields": [
> 
> "authorName",
> 
> "authorTags",
> 
> "cnt_en",
> 
> "permalink",
> 
> "t_en"
> 
> ],
> 
> "type": "boolean",
> 
> "operator": "AND",
> 
> "use_dis_max": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> "boost": 1
> 
> }
> 
> },
> 
> "filter": {
> 
> "and": {
> 
> "filters": [
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorCountry": "United States",
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "or": {
> 
> "filters": [
> 
> {
> 
> "term": {
> 
> "authorLanguage": 12,
> 
> "_cache": false
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> {
> 
> "numeric_range": {
> 
> "publishedDate": {
> 
> "from": 1356220800000,
> 
> "to": 1358985600000,
> 
> "include_lower": true,
> 
> "include_upper": true
> 
> }
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> On Monday, January 21, 2013 3:32:16 PM UTC-8, suleman mubarik wrote:
> 
> > Hi I have this search query (Ford in Detroit)
> > 
> > It is evaluating as (Ford AND in AND Detroit)
> > 
> > When I apply the stop word filter (analyzer) it become (Ford AND AND  
> > Detroit)
> > 
> > When I run this
> > 
> > Here is the JSON which ES is evaluating
> > 
> > { "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
> > "must" : [ { "multi\_match" : { "query" : "in", "fields" : [  
> > "authorName", "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" :  
> > "boolean", "operator" : "AND", "use\_dis\_max" : false } }, {  
> > "multi\_match" : { "query" : "Detroit", "fields" : [ "authorName",  
> > "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
> > "operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : { "query"  
> > : "Ford", "fields" : [ "authorName", "authorTags", "cnt\_en", "permalink",  
> > "t\_en" ], "type" : "boolean", "operator" : "AND", "use\_dis\_max" : false } }  
> > ] } }, "boost" : 1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : {  
> > "filters" : [ { "term" : { "authorCountry" : "United States", "\_cache" :  
> > false } } ] } }, { "or" : { "filters" : [ { "term" : { "authorLanguage" :  
> > 12, "\_cache" : false } } ] } }, { "numeric\_range" : { "publishedDate" : {  
> > "from" : 1355616000000, "to" : 1358467199999, "include\_lower" : true,  
> > "include\_upper" : true } } } ] } } } }
> > 
> > Is there a way so the ES analyzer remove the multi\_match when it find the  
> > stop word and in that case my search term will become (Ford AND Detroit)
> > 
> > or any idea how can i remove this
> > 
> > Thanks
> 
> --

--

---

<div class="post-metadata">

**Author:** ![sulemanmubarik](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sulemanmubarik](https://discuss.elastic.co/u/sulemanmubarik)\
**Post date:** [January 23, 2013, 8:19pm UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/5 "2013-01-23T20:19:58Z")

</div>

Thanks Matt

Yes it will work for this case but if i have an other case ("foo bar " the)  
where "foo bar "is a phrase and the is a stop word in this i will have  
again 2 multi\_match and i will get no results where i should get same  
result as for "foo bar"

On Monday, January 21, 2013 3:32:16 PM UTC-8, suleman mubarik wrote:

> Hi I have this search query (Ford in Detroit)
> 
> It is evaluating as (Ford AND in AND Detroit)
> 
> When I apply the stop word filter (analyzer) it become (Ford AND AND  
> Detroit)
> 
> When I run this
> 
> Here is the JSON which ES is evaluating
> 
> { "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
> "must" : [ { "multi\_match" : { "query" : "in", "fields" : [ "authorName",  
> "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
> "operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : {  
> "query" : "Detroit", "fields" : [ "authorName", "authorTags", "cnt\_en",  
> "permalink", "t\_en" ], "type" : "boolean", "operator" : "AND",  
> "use\_dis\_max" : false } }, { "multi\_match" : { "query" : "Ford", "fields" :  
> ["authorName", "authorTags", "cnt\_en", "permalink", "t\_en"], "type" :  
> "boolean", "operator" : "AND", "use\_dis\_max" : false } } ] } }, "boost" :  
> 1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : { "filters" : [ {  
> "term" : { "authorCountry" : "United States", "\_cache" : false } } ] } }, {  
> "or" : { "filters" : [ { "term" : { "authorLanguage" : 12, "\_cache" : false  
> } } ] } }, { "numeric\_range" : { "publishedDate" : { "from" :  
> 1355616000000, "to" : 1358467199999, "include\_lower" : true,  
> "include\_upper" : true } } } ] } } } }
> 
> Is there a way so the ES analyzer remove the multi\_match when it find the  
> stop word and in that case my search term will become (Ford AND Detroit)
> 
> or any idea how can i remove this
> 
> Thanks

--

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [January 23, 2013, 9:06pm UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/6 "2013-01-23T21:06:11Z")

</div>

You can use query\_string which is similar to match queries, but does more  
processing on the query string. Using query\_string you can do something  
like:

ejs.Request()  
.query(  
ejs.FilteredQuery(  
ejs.QueryStringQuery(""foo bar" the")

.fields(["authorName","authorTags","cnt\_en","permalink","t\_en"])  
.defaultOperator('and')  
.useDisMax(false),  
ejs.AndFilter([  
ejs.TermsFilter('authorCountry', ['United States'])  
.cache(false),  
ejs.TermsFilter('authorLanguage', [12])  
.cache(false),  
ejs.NumericRangeFilter('publishedDate')  
.from(1355616000000)  
.to(1358467199999)  
.includeLower(true)  
.includeUpper(true)  
])));

In this case "foo bar" will be a phrase, and the will get not be considered.

Thanks,  
Matt Weber

On Wed, Jan 23, 2013 at 12:19 PM, suleman mubarik  
[sulemanmubarik@gmail.com](mailto:sulemanmubarik@gmail.com)wrote:

> Thanks Matt
> 
> Yes it will work for this case but if i have an other case ("foo bar " the)  
> where "foo bar "is a phrase and the is a stop word in this i will have  
> again 2 multi\_match and i will get no results where i should get same  
> result as for "foo bar"
> 
> On Monday, January 21, 2013 3:32:16 PM UTC-8, suleman mubarik wrote:
> 
> > Hi I have this search query (Ford in Detroit)
> > 
> > It is evaluating as (Ford AND in AND Detroit)
> > 
> > When I apply the stop word filter (analyzer) it become (Ford AND AND  
> > Detroit)
> > 
> > When I run this
> > 
> > Here is the JSON which ES is evaluating
> > 
> > { "filtered" : { "query" : { "constant\_score" : { "query" : { "bool" : {  
> > "must" : [ { "multi\_match" : { "query" : "in", "fields" : [  
> > "authorName", "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" :  
> > "boolean", "operator" : "AND", "use\_dis\_max" : false } }, {  
> > "multi\_match" : { "query" : "Detroit", "fields" : [ "authorName",  
> > "authorTags", "cnt\_en", "permalink", "t\_en" ], "type" : "boolean",  
> > "operator" : "AND", "use\_dis\_max" : false } }, { "multi\_match" : { "query"  
> > : "Ford", "fields" : [ "authorName", "authorTags", "cnt\_en", "permalink",  
> > "t\_en" ], "type" : "boolean", "operator" : "AND", "use\_dis\_max" : false } }  
> > ] } }, "boost" : 1.0 } }, "filter" : { "and" : { "filters" : [ { "or" : {  
> > "filters" : [ { "term" : { "authorCountry" : "United States", "\_cache" :  
> > false } } ] } }, { "or" : { "filters" : [ { "term" : { "authorLanguage" :  
> > 12, "\_cache" : false } } ] } }, { "numeric\_range" : { "publishedDate" : {  
> > "from" : 1355616000000, "to" : 1358467199999, "include\_lower" : true,  
> > "include\_upper" : true } } } ] } } } }
> > 
> > Is there a way so the ES analyzer remove the multi\_match when it find the  
> > stop word and in that case my search term will become (Ford AND Detroit)
> > 
> > or any idea how can i remove this
> > 
> > Thanks
> 
> --

--

---

<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:54am UTC](https://discuss.elastic.co/t/es-multi-match-problem/10445/7 "2017-07-06T02:54:54Z")

</div>


