忽略词序的 Azure 认知搜索建议
Azure cognitive search suggestion ignoring word order
假设在我的索引中我有这个值:
Clint Eastwood
Jamie Lee Curtis
我有这个代码简码
public void Search(string indexName, string suggester, string name)
{
var searchClient = new SearchClient(new Uri(searchServiceEndPoint), indexName , new AzureKeyCredential(adminApiKey));
var so = new SuggestOptions();
var sugg = searchClient.Suggest<Request>(name, suggester, so);
}
进行以下搜索我得到了这个结果
Working examples:
name = clin
Suggetsion is Clint Eastwood
name = east
Suggestion is Clint Eastwood
name = clint eas
Suggestion is Clint Eastwood
Not working examples
name = eastwood cl
no suggestion
name = jamie curtis
no suggestions
有没有办法让 azure 搜索不太严格,以便为两个不工作的示例提供建议?
这是自动完成的常见用例。我的解决方案是在将内容提交到索引之前对内容进行令牌轮换。然后,您的建议将基于旋转版本而不是名称。
{
"value": [
{
"@search.action": "mergeOrUpload",
"Id": "1",
"Name": "Clint Eastwood",
"Rotated": ["Clint Eastwood", "Eastwood Clint"]
},
{
"@search.action": "mergeOrUpload",
"Id": "2",
"Name": "Jamie Lee Curtis",
"Rotated": ["Jamie Lee Curtis", "Lee Curtis Jamie", "Curtis Jamie Lee"]
}
]
}
我通常将令牌向左旋转,直到像上面那样。请注意,这不会解决您获得输入 jamie curtis 的建议的要求。但是,您可以通过生成额外的令牌迭代来解决这个问题。
假设在我的索引中我有这个值:
Clint Eastwood
Jamie Lee Curtis
我有这个代码简码
public void Search(string indexName, string suggester, string name)
{
var searchClient = new SearchClient(new Uri(searchServiceEndPoint), indexName , new AzureKeyCredential(adminApiKey));
var so = new SuggestOptions();
var sugg = searchClient.Suggest<Request>(name, suggester, so);
}
进行以下搜索我得到了这个结果
Working examples:
name = clin
Suggetsion is Clint Eastwood
name = east
Suggestion is Clint Eastwood
name = clint eas
Suggestion is Clint Eastwood
Not working examples
name = eastwood cl
no suggestion
name = jamie curtis
no suggestions
有没有办法让 azure 搜索不太严格,以便为两个不工作的示例提供建议?
这是自动完成的常见用例。我的解决方案是在将内容提交到索引之前对内容进行令牌轮换。然后,您的建议将基于旋转版本而不是名称。
{
"value": [
{
"@search.action": "mergeOrUpload",
"Id": "1",
"Name": "Clint Eastwood",
"Rotated": ["Clint Eastwood", "Eastwood Clint"]
},
{
"@search.action": "mergeOrUpload",
"Id": "2",
"Name": "Jamie Lee Curtis",
"Rotated": ["Jamie Lee Curtis", "Lee Curtis Jamie", "Curtis Jamie Lee"]
}
]
}
我通常将令牌向左旋转,直到像上面那样。请注意,这不会解决您获得输入 jamie curtis 的建议的要求。但是,您可以通过生成额外的令牌迭代来解决这个问题。