0
我在得到同義詞使用Nest API在彈性工作真正的麻煩在Elasticsearch使用同義詞。通過巢
我建立了我的索引和所有適當的設置,但是當我查詢基於一個術語,應該是一個代名詞,因爲如果他們沒有在所有應用的結果出現。這裏是我的設置:
m_objNode = new Uri(Properties.Settings.Default.strLocalElasticSearchURL);
m_objConnectionSettings = new ConnectionSettings(m_objNode, defaultIndex: "myIndex");
m_objElasticClient = new ElasticClient(m_objConnectionSettings);
IndexSettings indexSettings = new IndexSettings();
indexSettings.NumberOfReplicas = 1;
indexSettings.NumberOfShards = 1;
CustomAnalyzer exclamation = new CustomAnalyzer();
exclamation.Tokenizer = "exclamationTokenizer";
indexSettings.Analysis.Tokenizers.Add("exclamationTokenizer", new PatternTokenizer {
Pattern = @"!"
});
indexSettings.Analysis.Analyzers.Add("exclamation", exclamation);
indexSettings.Analysis.TokenFilters.Add("synonym", new SynonymTokenFilter { Synonyms = new[] { "tire => tyre", "aluminum => aluminium" }, IgnoreCase = true, Tokenizer = "whitespace" });
m_objElasticClient.CreateIndex(c => c
.Index("myIndex")
.InitializeUsing(indexSettings)
.AddMapping<myClass>(m => m
.MapFromAttributes()
.IndexAnalyzer("english")
.SearchAnalyzer("english")
));
而且對象我索引是這樣的:
[ElasticType(IdProperty = "JAUniqueKey")]
public class myClass {
public string JAUniqueKey { get; set; }
public int JAItemID { get; set; }
public string JATitle { get; set; }
public string JABody { get; set; }
}
我試圖讓場JATitle和JABody與同義詞對齊。
任何想法當然會受到歡迎。
感謝, ScrappyT
您使用的是哪種版本的NEST和elasticsearch? – Rob
喜羅布,道歉的延遲,我一直在年假。我爲Nest和ElasticSeach所使用的DLL是1.4.2版 - ElasticSearch節點本身正在運行1.7.5 - 謝謝,ScrappyT – ScrappyTexas