我正在尝试使用以下代码启用到某些字段的同义词映射: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:这些字段是可搜索和字符串类型的。
1 回答
翻过高山走不出你
TA贡献1875条经验 获得超3个赞
在同义词映射的定义中,'@' 将字符串内容标记为逐字文字,规则变为 dolve,douve => dove\n,以“\n”结尾。此同义词规则将查询“dolve”重写为“dove\n”。如果在同义词定义中删除 '@' 前缀或删除新行 '\n',同义词将按预期工作。
- 1 回答
- 0 关注
- 161 浏览
添加回答
举报
0/150
提交
取消