# Elasticsearch search based on term position and fuzzy

**URL:** <https://discuss.elastic.co/t/elasticsearch-search-based-on-term-position-and-fuzzy/340163>\
**Category:** Elasticsearch\
**Created:** [August 4, 2023, 10:39pm UTC](https://discuss.elastic.co/t/elasticsearch-search-based-on-term-position-and-fuzzy/340163 "2023-08-04T22:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnsM](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnsM](https://discuss.elastic.co/u/JohnsM)\
**Post date:** [August 4, 2023, 10:39pm UTC](https://discuss.elastic.co/t/elasticsearch-search-based-on-term-position-and-fuzzy/340163/1 "2023-08-04T22:39:30Z")

</div>

I am a beginner in Elasticsearch and I try to combine a query with term position and fuzzy and the results are not what I expected.

I tried this query

```auto
{
    "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "must": [
                            {
                                "query_string": {
                                    "query": "douille~ raccordment~",
                                    "fields": [
                                        "name^10"
                                    ],
                                    "default_operator": "AND",
                                    "fuzziness": "AUTO:10,20"
                                }
                            }
                        ],
                        "should": [
                            {
                                "span_first": {
                                    "match": {
                                        "span_multi": {
                                            "match": {
                                                "fuzzy": {
                                                    "name": {
                                                        "value": "douille",
                                                        "fuzziness": "AUTO"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "end": 1
                                }
                            },
                            {
                                "span_first": {
                                    "match": {
                                        "span_multi": {
                                            "match": {
                                                "fuzzy": {
                                                    "name": {
                                                        "value": "douille",
                                                        "fuzziness": "AUTO"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "end": 2
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

```

The word "raccordment" isn't spelled well (in French). The right word is "raccordement". I have a product "Douille Raccordement" in my index and products with "Douille" without "Raccordement" in the name but not in the first position in my index. When I try the query, I have no result.

My aim is to have this kind of results with the search "douille raccordment" (based on term position, with or without misspell):

- Douille Raccordement
- Douille 1
- 10 Douilles
- Raccordement 1
- Raccordement 2

I use Elasticsearch 7.

Do you know why?

Thanks for your help

---

<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 1, 2023, 10:40pm UTC](https://discuss.elastic.co/t/elasticsearch-search-based-on-term-position-and-fuzzy/340163/2 "2023-09-01T22:40:30Z")

</div>

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