How Can i use Azure Search Like Syntax

2019-08-28 08:19发布

问题:

In my Azure Search , i have two document , one column is call "Description"

And two record like this

[ 
{"Description": "XARATM | KONE"},
{"Description": "ATM | RCOR"}
]

my problem is , when i use Azure Search to search my record like:

https://myservice.search.windows.net/indexes/searchproduct/docs?search=ATM&api-version=2014-07-31-Preview

they just return one record {"Description": "ATM | RCOR"} , but i need two record. so can i use some syntax like T-SQL

SELECT * FROM SearchProduct WHERE Description Like '%ATM%'

Thank you

回答1:

Azure Search does support wildcards, but only in the format ATM*, that would allow to search for words in the form of suffixes such as ATMa or ATMb. In your case, you would need *ATM, which is not currently supported with Azure Search.

To learn more about wildcards for suffix, please visit the MSDN API documentation on this topic here.

Liam



回答2:

Although you can't use prefix wildcards in Azure search, you can use regular expressions which may be able to handle allowing some variance in your search criteria.

https://littlekendra.com/2016/10/25/wildcard-vs-regular-expressions-lucene-query-in-azure-search/

Examples:

business_title:/(Sen|Jun)ior/

business_title:/(.)rchit(.)/