我将我的 SQL 数据迁移到 AzureSearch 文档中以尝试新的搜索体验。我无法使用 .net sdk (3.0.4) 过滤数据
public IActionResult Search(string state, string category, string search, short pageNumber = 1, short pageSize = 10)
{
SearchIndexClient indexClient = new SearchIndexClient(searchServiceName, "search", new SearchCredentials(searchServiceApiKey));
DocumentSearchResult<SearchResultDto> results = null;
if (string.IsNullOrWhiteSpace(search))
search = "*";
if (state.Equals("All", StringComparison.InvariantCultureIgnoreCase))
state = string.Empty;
SearchParameters parameters = new SearchParameters()
{
Filter = "state eq " + state,
Top = pageSize,
Skip = (pageNumber - 1) * pageSize,
SearchMode = SearchMode.All,
IncludeTotalResultCount = true
};
try
{
results = indexClient.Documents.Search<SearchResultDto>(search, parameters);
return Ok(results.Results);
}
catch (Exception ex)
{
Console.WriteLine("Error querying index: {0}\r\n", ex.Message.ToString());
throw ex;
}
}
我收到错误“调用的目标已引发异常”。
参数原始值:$count=true&$filter=state%20eq%20&queryType=simple&searchMode=all&$skip=0&$top=10
当我在 AzureSearch explore 中使用参数值时,我收到错误 Invalid expression: Expression expected at position 19 in 'state eq delhi eq'。\r\n参数名称:$filter
我的代码有什么问题??