public void PrefixSearchTest() { var searcher = new StringSearcher <int>(SearchType.Prefix, m_wsManager); searcher.Add(0, 0, TsStringUtils.MakeString("test", m_enWs)); searcher.Add(1, 0, TsStringUtils.MakeString("Hello", m_enWs)); searcher.Add(2, 0, TsStringUtils.MakeString("c'est une phrase", m_frWs)); searcher.Add(3, 0, TsStringUtils.MakeString("hello", m_enWs)); searcher.Add(4, 0, TsStringUtils.MakeString("zebra", m_enWs)); CheckSearch(searcher, TsStringUtils.MakeString("test", m_enWs), new[] { 0 }); CheckSearch(searcher, TsStringUtils.MakeString("hel", m_enWs), new[] { 1, 3 }); CheckSearch(searcher, TsStringUtils.MakeString("zebra", m_enWs), new[] { 4 }); CheckSearch(searcher, TsStringUtils.MakeString("c'est", m_frWs), new[] { 2 }); CheckNoResultsSearch(searcher, TsStringUtils.MakeString("zebras", m_enWs)); }
public void FullTextSearchTest() { var searcher = new StringSearcher <int>(SearchType.FullText, m_wsManager); searcher.Add(0, 0, TsStringUtils.MakeString("test", m_enWs)); searcher.Add(1, 0, TsStringUtils.MakeString("c'est une phrase", m_frWs)); ITsIncStrBldr tisb = TsStringUtils.MakeIncStrBldr(); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_frWs); tisb.Append("C'est une sentence. "); tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_enWs); tisb.Append("We use it for testing purposes."); searcher.Add(2, 0, tisb.GetString()); searcher.Add(3, 0, TsStringUtils.MakeString("Hello, how are you doing? I am doing fine. That is good to know.", m_enWs)); CheckSearch(searcher, TsStringUtils.MakeString("test", m_enWs), new[] { 0, 2 }); CheckSearch(searcher, TsStringUtils.MakeString("c'est une", m_frWs), new[] { 1, 2 }); CheckSearch(searcher, TsStringUtils.MakeString("t", m_enWs), new[] { 0, 2, 3 }); CheckSearch(searcher, TsStringUtils.MakeString("testing purpose", m_enWs), new[] { 2 }); }