我正在嘗試使用以下代碼啟用到某些字段的同義詞映射: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 關注
- 176 瀏覽
添加回答
舉報
0/150
提交
取消