# I'm using "match-Boolean-prefix query but I can't get the exact match of the query

**URL:** https://discuss.elastic.co/t/im-using-match-boolean-prefix-query-but-i-cant-get-the-exact-match-of-the-query/312492
**Category:** Elasticsearch
**Created:** [August 19, 2022, 6:18pm UTC](https://discuss.elastic.co/t/im-using-match-boolean-prefix-query-but-i-cant-get-the-exact-match-of-the-query/312492 "2022-08-19T18:18:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![paris1](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@paris1](https://discuss.elastic.co/u/paris1)
#### Post date: [August 19, 2022, 6:18pm UTC](https://discuss.elastic.co/t/im-using-match-boolean-prefix-query-but-i-cant-get-the-exact-match-of-the-query/312492/1 "2022-08-19T18:18:57Z")

</div>

I'm using "match-Boolean-prefix query but I can't get the exact match of the query.I can't use prefix queries because I also need "not exact match" results and I also need the fuzziness and word completion.I get every thing I need by match-boo-prefix query(the fuzziness not work that good though) but my problem is when I'm looking for exact match like "apple" it shows everything that includes "apple" I need the exact match gets higher ranking than others.

```auto
   GET /_search
{
    "query": {
        "bool": {
            "must": [
                {
                    "match_bool_prefix": {
                        "name": {
                            "query": "apple",
                            "fuzziness": "auto"
                        }
                    }
                },
                {
                    "bool": {
                        "must_not": [
                            {
                                "match": {
                                    "type": "3"
                                }
                            },
                            {
                                "match": {
                                    "type": "4"
                                }
                            }
                        ]
                    }
                },
                {
                    "match": {
                        "status": "A"
                    }
                }
            ],
            "should": [
                {
                    "exists": {
                        "field": "",
                        "boost": 10
                    }
                }
            ]
        }
    },
    "indices_boost": [
        {
            "index1": 3
        },
        {
            "index2": 1.3
        },
        {
            "index3": 1.5
        }
    ],
    "size": 20
} 

```

the result I'm getting with this query is :

```auto
{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 20,
    "successful" : 20,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4970,
      "relation" : "eq"
    },
    "max_score" : 14.451834,
    "hits" : [
      {
        "_index" : "index",
        "_id" : "11434",
        "_score" : 14.451834,
        "_source" : {
           "name" : "Apple Slices With Peanut Butter". 

```

is there any solution for this?

---

<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: [September 16, 2022, 6:19pm UTC](https://discuss.elastic.co/t/im-using-match-boolean-prefix-query-but-i-cant-get-the-exact-match-of-the-query/312492/2 "2022-09-16T18:19:30Z")

</div>

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