首页 > 解决方案 > Lucene.NET 2-Way Synonyms

问题描述

I'm able to get synonyms working in my custom analyzer, but it only appears to behave correctly if the phrase entered matches the input "key". I'd like to be able to match any synonym in a list of 2+ with any other synonym in that same list.

        var map = new SynonymMap.Builder(true);
        var synonyms = string.Join("\0", new string[] { "broken", "break", "malfunction" });
        map.Add(new CharsRef("broke"), new CharsRef(synonyms), true);

        stream = new SynonymFilter(stream, map.Build(), true);

Am I supposed to add a map for each synonym?

        var synonyms2 = string.Join("\0", new string[] { "broke", "break", "malfunction" });
        map.Add(new CharsRef("broken"), new CharsRef(synonyms2), true);
        var synonyms3 = string.Join("\0", new string[] { "broken", "break", "broke" });
        map.Add(new CharsRef("malfunction"), new CharsRef(synonyms3), true);

I can clean it up so it loops through a list and adds a map for each one, I just wanted to keep the issue clear.

If I have a database that manages synonyms for hundreds or thousands of words... is it expected to simply add tens of thousands of maps for every possible combination?

标签: mappinglucene.netsynonym

解决方案


推荐阅读