# Multi\_match prefix query working weird

**URL:** <https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148>\
**Category:** Elasticsearch\
**Created:** [January 29, 2019, 11:16am UTC](https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148 "2019-01-29T11:16:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent.charlanne](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vincent.charlanne](https://discuss.elastic.co/u/vincent.charlanne)\
**Post date:** [January 29, 2019, 11:16am UTC](https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148/1 "2019-01-29T11:16:35Z")

</div>

Hi everyone,

Don't know if i post this in the right section, sorry if i'm wrong.

Here is my case.

I use ElasticSearch to optimize search engine on a wordpress site using ElasticPress plugin as bridge.  
I work with a local ElasticSearch installation (version 6.2).

To those who don't have yet fled, here my problem.

I'm working with a french database, this is my analyzer setting :

```
array(
    'analyzer' => array(
        'default' => array(
            'tokenizer' => 'icu_tokenizer',
            'filter' => array(
                'french_elision',
                'lowercase',
                'french_stop',
                'french_stemmer',
                'icu_folding'
            ),
            'char_filter' => array( 'html_strip' ),
            'language' => apply_filters( 'ep_analyzer_language', 'french', 'analyzer_default' ),
        )
    ),
    'filter' => array(
        'french_elision' => array(
            'type' => 'elision',
            'articles_case' => true,
            'articles' => [
                'l', 'm', 't', 'qu', 'n', 's',
                'j', 'd', 'c', 'jusqu', 'quoiqu',
                'lorsqu', 'puisqu'
            ]
        ),
        'french_stop' => array(
          'type' => 'stop',
          'stopwords' => '_french_'
        ),
        'french_stemmer' => array(
            'type' => 'stemmer',
            'language' => 'light_french'
        )
    ),
    'normalizer' => array(
        'lowerasciinormalizer' => array(
            'type' => 'custom',
            'filter' => array( 'lowercase', 'icu_folding' ),
        )
    )
)

```

and this is the last thing i try as query :

```
"query": {
    "function_score": {
        "query": {
            "bool": {
                "should": [
                    {
                        "multi_match": {
                            "query": "managemen",
                            "type": "phrase",
                            "fields": [
                                "post_title",
                                "post_content",
                                "post_excerpt"
                            ],
                            "boost": 4
                        }
                    },
                    {
                        "multi_match": {
                            "query": "managemen",
                            "fields": [
                               "post_title",
                                "post_content",
                                "post_excerpt"
                            ],
                            "boost": 2,
                            "operator": "and"
                        }
                    },
                    {
                        "multi_match": {
                            "query": "managemen",
                            "fields": [
                                "post_title",
                                "post_content",
                                "post_excerpt"
                            ],
                            "boost": 2,
                            "operator": "and",
                            "type": "phrase_prefix"
                        }
                    },
                    {
                        "multi_match": {
                            "query": "managemen",
                            "fields": [
                               "post_title",
                                "post_content",
                                "post_excerpt"
                            ],
                            "boost": 2,
                            "type": "phrase_prefix"
                        }
                    },
                    {
                        "prefix": {
                            "post_title": "managemen"
                        }
                    },
                    {
                        "prefix": {
                            "post_content": "managemen"
                        }
                    },
                    {
                        "prefix": {
                            "post_excerpt": "managemen"
                        }
                    }
                ]
            }
        },
        "score_mode": "sum",
        "boost_mode": "sum"
    }
}

```

I know there is a lot of thing in this bool score function, it started with some simples multi\_match queries to match phrase on multiple fields. And by trying to resolve my problem, i'm finishing by try every possibility (mutli\_match type phrase\_prefix, multiple prefix term query, ...)

So, my problem is if i search the term "manage", i will see a lot of results.  
Those results are elements with fields composed of terms "manage", "manager" or "management".  
If i search the term "management", i will see a lot of results.  
Those results are elements with fields composed of terms "management".  
If i search the term "manageme", i will see no results at all...

I don't understand why i don't have result with a multi\_match phrase\_prefix query types and multiple term prefixs query...

If you have any clue, please feel free to light my mind...

---

<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:** [January 29, 2019, 11:28am UTC](https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148/2 "2019-01-29T11:28:40Z")

</div>

You should use the \_analyze API to understand how your text is transformed at index time and search time.  
That might give you some clues

---

<div class="post-metadata">

**Author:** ![vincent.charlanne](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vincent.charlanne](https://discuss.elastic.co/u/vincent.charlanne)\
**Post date:** [January 29, 2019, 11:42am UTC](https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148/3 "2019-01-29T11:42:58Z")

</div>

hi dadoonet,

thanks for your advise !

I'm thinking that the answer to my problem is how indexes are done and not how i query them.  
I will investigate more on this side.

If anybody have another idea, i will look at it 😉

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:** [February 26, 2019, 11:54am UTC](https://discuss.elastic.co/t/multi-match-prefix-query-working-weird/166148/4 "2019-02-26T11:54:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
