public void TermSearchTest() { var index = CreateDictionaryIndex(); var engine = new BooleanSearchEngine <string>(index, s => s.ToLower()); foreach (var kv in IndexHelper.Results) { var query = BooleanQuery.CreateTerm(kv.Key); Assert.Equal(kv.Value, engine.ExecuteQuery(query).ToArray()); } }
public void OperatorNotSearchTest() { var index = CreateDictionaryIndex(); var engine = new BooleanSearchEngine <string>(index, s => s.ToLower()); var tests = new List <(BooleanQuery Query, DocumentId[] Result)> { (BooleanQuery.CreateOr("earth", "great", "ocean"), new [] { new DocumentId(1), new DocumentId(10), new DocumentId(11), }), (BooleanQuery.CreateOr("pacific", "ocean", "earth"), new [] { new DocumentId(0), new DocumentId(1), new DocumentId(10), new DocumentId(11), }), (BooleanQuery.CreateTerm("moon"), IndexHelper.AllDocuments), (BooleanQuery.CreateTerm("the"), Array.Empty <DocumentId>()), }; foreach (var test in tests) { Assert.Equal(test.Result, engine.ExecuteQuery(BooleanQuery.CreateNot(test.Query)).ToArray()); } }