# Unable to Search middle substring of word from sentence

**URL:** <https://forum.opensearch.org/t/unable-to-search-middle-substring-of-word-from-sentence/16771>\
**Category:** OpenSearch\
**Created:** [November 21, 2023, 9:58am UTC](https://forum.opensearch.org/t/unable-to-search-middle-substring-of-word-from-sentence/16771 "2023-11-21T09:58:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amit.cs13](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@amit.cs13](https://forum.opensearch.org/u/amit.cs13)\
**Post date:** [November 21, 2023, 9:58am UTC](https://forum.opensearch.org/t/unable-to-search-middle-substring-of-word-from-sentence/16771/1 "2023-11-21T09:58:45Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
1.3

**Describe the issue** :  
Unable to Search middle substring of word from sentence

**Configuration** :  
aws open search 1.3 version

**Relevant Logs or Screenshots** :  
target skuit name : CHOC Milk 24X125ml

request:  
{  
“from”: 0,  
“size”: 100,  
“query”: {  
“bool”: {  
“filter”: [  
{  
“terms”: {  
“company\_id”: [  
1740  
],  
“boost”: 1  
}  
},  
{  
“term”: {  
“is\_active”: {  
“value”: true,  
“boost”: 1  
}  
}  
},  
{  
“terms”: {  
“isvisible\_retailer”: [  
true  
],  
“boost”: 1  
}  
}  
],  
“should”: [  
{  
“query\_string”: {  
“query”: “(125\*)”,  
“default\_field”: “name”,  
“fields”: ,  
“type”: “best\_fields”,  
“default\_operator”: “or”,  
“max\_determinized\_states”: 10000,  
“enable\_position\_increments”: true,  
“fuzziness”: “AUTO”,  
“fuzzy\_prefix\_length”: 0,  
“fuzzy\_max\_expansions”: 50,  
“phrase\_slop”: 0,  
“analyze\_wildcard”: true,  
“escape”: false,  
“auto\_generate\_synonyms\_phrase\_query”: true,  
“fuzzy\_transpositions”: true,  
“boost”: 1  
}  
}  
],  
“adjust\_pure\_negative”: true,  
“minimum\_should\_match”: “1”,  
“boost”: 1  
}  
},  
“highlight”: {  
“fields”: {  
“name”: {}  
}  
}  
}  
response :  
{  
“took”: 23,  
“timed\_out”: false,  
“\_shards”: {  
“total”: 16,  
“successful”: 16,  
“skipped”: 0,  
“failed”: 0  
},  
“hits”: {  
“total”: {  
“value”: 0,  
“relation”: “eq”  
},  
“max\_score”: null,  
“hits”:   
}  
}

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [November 23, 2023, 6:05am UTC](https://forum.opensearch.org/t/unable-to-search-middle-substring-of-word-from-sentence/16771/2 "2023-11-23T06:05:38Z")

</div>

Firstly, you can use the \_analyze API to check the generated tokens for that text:

```auto
POST test1/_analyze
{
  "text": "CHOC Milk 24X125ml"
}

```

, you can see that that text generates 3 tokens by default analyzer:

```auto
{
  "tokens": [
    {
      "token": "choc",
      "start_offset": 0,
      "end_offset": 4,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "milk",
      "start_offset": 5,
      "end_offset": 9,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "24x125ml",
      "start_offset": 10,
      "end_offset": 18,
      "type": "<ALPHANUM>",
      "position": 2
    }
  ]
}

```

, so in order to match the token `24x125ml`, you need to query `*125*` instead of `125*`.
