Search in substring

aaaghh
defagee
ccacc
aaa agh
ddgdd
rarrgrr
bbbaghjj

I have these values in Name column. I need to get only strings contains "ag". How can I implement it in elasticsearch?

GET /student/_search
    {
                  "from": 0,
                  "size": 1000,
                  "query": {
                      "bool": {
                         "must": [
                             { 
                                  "match_phrase_prefix": {
                                        "Name": "*ag*"
                                  }
                              }
                        ]
                      }
             }
        }

The query is giving only "aaa agh" as result. I think match prefix will return only those strings starts with pattern(words). Is there any other query?

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

I’d look at ngrams for that.

Hi

Can u just check

Thanks
Aneesh

I already answered I think with Search in substring - #2 by dadoonet

I’d look at ngrams for that.

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