我正在尝试使用以下代码为某些字段启用同义词映射:
public ActionResult ConfigFieldToUseSynonyn()
{
string searchServiceName = "xxx";
string apiKey = "123123123123123123123123123";
SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(apiKey));
var index = serviceClient.Indexes.Get("produtos");
index.Fields[2].SynonymMaps = new string[] { "marca-synonymmap" };
index.Fields[7].SynonymMaps = new string[] { "marca-synonymmap" };
serviceClient.Indexes.CreateOrUpdate(index, accessCondition: AccessCondition.IfNotChanged(index));
return Content("OK");
}
以及使用以下代码的定义:
public ActionResult Synonym()
{
string searchServiceName = "xxx";
string apiKey = "123123123123123123123123123";
SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(apiKey));
var indexClient = serviceClient.Indexes.GetClient("produtos");
var synonymMap = new SynonymMap()
{
Name = "marca-synonymmap",
Format = "solr",
Synonyms = @"
dolve, douve => dove\n
"
};
serviceClient.SynonymMaps.CreateOrUpdate(synonymMap);
return Content("OK");
}
当我尝试使用“dolve”查找产品时,它并没有映射到“dove”。我错过了什么?
PS:这些字段是可搜索的和字符串类型的。