Search code examples
azureazure-cognitive-search

How to search for a partial string in a specific field in Azure Search?


I have an index with a title field. In it, I have the following text: Bakersfield Memorial Hospital.

I would like to be able to search by a partial string. The following queries works:

search=*&$filter=search.ismatch('bakersfield','title')
search=*&$filter=search.ismatch('memorial','title')

However, if I were to search on a partial string of the word, it doesn't. For instance:

search=*&$filter=search.ismatch('baker','title')

So how do I search for partial word?


Solution

  • Answering my own question in case someone needs this.

    You could use the * operator like this:

    search=*&$filter=search.ismatch('baker*','title')
    

    However, that only works for a begins with search. It doesn't work for a contains or ends with. For instance, the following doesn't work:

    search=*&$filter=search.ismatch('*field','title')