public void AddTextFieldToSearch_Adds_Type()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AddTextFieldToSearch(LibrarySearchCriteria.SearchableTextField.Names);

            Assert.AreEqual(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels, LibrarySearchCriteria.SearchableTextField.Definitions, LibrarySearchCriteria.SearchableTextField.Names }, crit.TextFieldsToSearch);
        }
        public void AddIncludingWord_Appends_Word()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AddOptionalWord("Joey")
                .AddOptionalWord("Lawrence");

            Assert.AreEqual(new string[] { "Joey", "Lawrence" }, crit.OptionalWords);
        }
        public void AddRequiredWord_Appends_Word()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AddRequiredWord("Joey")
                .AddRequiredWord("Lawrence");

            Assert.AreEqual(new string[] { "Joey", "Lawrence" }, crit.RequiredWords);
        }
        public void AddBalanceType_Adds_Type()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AddBalanceType(Element.BalanceType.credit)
                .AddBalanceType(Element.BalanceType.debit);

            Assert.AreEqual(new Element.BalanceType[] { Element.BalanceType.credit, Element.BalanceType.debit }, crit.BalanceTypes);
        }
        public void Path()
        {
            LibrarySearchCriteria criteria = new LibrarySearchCriteria()
                .WithRequiredWords("Hedging")
                .DescendingFrom("/Notes to the Financial Statements/usfr-pte_NotesFinancialStatementsAbstract/usfr-pte_GeneralNotesAbstract/usfr-pte_DerivativesHedgesNote");

            ILibrarySearchResult result = _indexMgr.Search(criteria);

            Assert.AreEqual(30,result.Count,"Num results");
        }
        public void ConvertPluralsToSingular_With_Gaming()
        {
            const string expectedResult = "(Label:(Gam*^1))";

            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .MatchingPartialWords()
                .WithOptionalWords("Gaming")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels });

            AssertQueryString(expectedResult, crit);
        }
        public void ConvertPluralsToSingular_With_Partial_Word_Matching()
        {
            const string expectedResult = "(Label:(\"Joes Fishes Exes Candies Dresses Handles\"~6 Joe*^6 Fish*^5 Exe*^4 Cand*^3 Dress*^2 Handl*^1))";

            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .MatchingPartialWords()
                .WithOptionalWords("Joes Fishes Exes Candies Dresses Handles")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels });

            AssertQueryString(expectedResult, crit);
        }
        public void AgainstTextFields_Clears_And_Adds_Range()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels });

            Assert.AreEqual(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels }, crit.TextFieldsToSearch);

            crit.AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Definitions });

            Assert.AreEqual(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Definitions }, crit.TextFieldsToSearch);
        }
        public void ConvertPluralsToSingular_With_Whole_Word_Matching()
        {
            const string expectedResult = "(Label:(\"Joes Fishes Exes Candies Dresses Handles\"~6 Joes^6 Fishes^5 Exes^4 Candies^3 Dresses^2 Handles^1))";
            //const string expectedResult = "(Label:Joes^6 Label:Fishes^5 Label:Exes^4 Label:Candies^3 Label:Dresses^2 Label:Handles^1)";

            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .MatchingWholeWords()
                .WithOptionalWords("Joes Fishes Exes Candies Dresses Handles")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels });

            AssertQueryString(expectedResult, crit);
        }
        public void OneOrMoreWords()
        {
            string expectedResult = "(Label:(\"Joe Dirt\"~6 Joe^8 Dirt^7) Definition:(Joe^6 Dirt^5) Name:(Joe^4 Dirt^3) References:(Joe^2 Dirt^1))";
            //string expectedResult = "(Label:Joe^8 Definition:Joe^6 Name:Joe^4 References:Joe^2 Label:Dirt^7 Definition:Dirt^5 Name:Dirt^3 References:Dirt^1)";

            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithOptionalWords("Joe Dirt")
                .MatchingWholeWords()
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[]
                                       {
                                           LibrarySearchCriteria.SearchableTextField.Labels,
                                           LibrarySearchCriteria.SearchableTextField.Definitions,
                                           LibrarySearchCriteria.SearchableTextField.Names,
                                           LibrarySearchCriteria.SearchableTextField.References
                                       });

            AssertQueryString(expectedResult,crit);
        }
Exemple #11
0
 /// <summary>
 /// </summary>
 public void UpdateFrom(LibrarySearchCriteria from)
 {
     requiredWords                 = from.requiredWords;
     optionalWords                 = from.optionalWords;
     prohibitedWords               = from.prohibitedWords;
     balanceTypes                  = from.balanceTypes;
     ancestryPath                  = from.ancestryPath;
     isIncludeAbstractElements     = from.isIncludeAbstractElements;
     isIncludeExtendedElements     = from.isIncludeExtendedElements;
     isIncludeOnlyExtendedElements = from.isIncludeOnlyExtendedElements;
     isMatchWholeWordsOnly         = from.isMatchWholeWordsOnly;
     textFieldsToSearch            = from.textFieldsToSearch;
     isConvertPluralsToSingular    = from.isConvertPluralsToSingular;
     sICPercentage                 = from.SICPercentage;
     sECPercentage                 = from.SECPercentage;
     includeSECPercentage          = from.includeSECPercentage;
     includeSICPercentage          = from.includeSICPercentage;
 }
        public void AbstractElements()
        {
            LibrarySearchCriteria includingAbstractCriteria = new LibrarySearchCriteria()
                .WithOptionalWords("SalesRevenueGoodsNetAbstract")
                .MatchingPartialWords()
                .IncludingAbstractElements()
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[]{LibrarySearchCriteria.SearchableTextField.Labels})
                .DescendingFrom("/124000 - Statement - Statement of Income (Including Gross Margin)");

            ILibrarySearchResult resultWithAbstract = _indexMgr.Search(includingAbstractCriteria);

            Assert.IsNotNull(resultWithAbstract, "Search results (with abstract elements) should not be null");
            Assert.AreEqual(1, resultWithAbstract.Count);

            LibrarySearchCriteria excludingAbstractCriteria = (includingAbstractCriteria.Clone() as LibrarySearchCriteria).ExcludingAbstractElements();

            ILibrarySearchResult resultWithoutAbstract = _indexMgr.Search(excludingAbstractCriteria);

            Assert.IsNotNull(resultWithoutAbstract, "Search results (without abstract elements) should not be null");
            Assert.AreEqual(0, resultWithoutAbstract.Count);
        }
Exemple #13
0
        /// <summary>
        /// </summary>
        public object Clone()
        {
            LibrarySearchCriteria result = new LibrarySearchCriteria();

            result.requiredWords                 = requiredWords;
            result.optionalWords                 = optionalWords;
            result.prohibitedWords               = prohibitedWords;
            result.balanceTypes                  = balanceTypes;
            result.ancestryPath                  = AncestryPath;
            result.isIncludeAbstractElements     = IsIncludeAbstractElements;
            result.isIncludeExtendedElements     = IsIncludeExtendedElements;
            result.isIncludeOnlyExtendedElements = IsIncludeOnlyExtendedElements;
            result.isMatchWholeWordsOnly         = IsMatchWholeWordsOnly;
            result.textFieldsToSearch            = textFieldsToSearch;
            result.isConvertPluralsToSingular    = isConvertPluralsToSingular;
            result.sICPercentage                 = sICPercentage;
            result.sECPercentage                 = sECPercentage;
            result.includeSECPercentage          = includeSECPercentage;
            result.includeSICPercentage          = includeSICPercentage;

            return(result);
        }
 /// <summary>
 /// </summary>
 public void UpdateFrom(LibrarySearchCriteria from)
 {
     requiredWords = from.requiredWords;
     optionalWords = from.optionalWords;
     prohibitedWords = from.prohibitedWords;
     balanceTypes = from.balanceTypes;
     ancestryPath = from.ancestryPath;
     isIncludeAbstractElements = from.isIncludeAbstractElements;
     isIncludeExtendedElements = from.isIncludeExtendedElements;
     isIncludeOnlyExtendedElements = from.isIncludeOnlyExtendedElements;
     isMatchWholeWordsOnly = from.isMatchWholeWordsOnly;
     textFieldsToSearch = from.textFieldsToSearch;
     isConvertPluralsToSingular = from.isConvertPluralsToSingular;
     sICPercentage = from.SICPercentage;
     sECPercentage = from.SECPercentage;
     includeSECPercentage = from.includeSECPercentage;
     includeSICPercentage = from.includeSICPercentage;
 }
        /// <summary>
        /// </summary>
        public object Clone()
        {
            LibrarySearchCriteria result = new LibrarySearchCriteria();
            result.requiredWords = requiredWords;
            result.optionalWords = optionalWords;
            result.prohibitedWords = prohibitedWords;
            result.balanceTypes = balanceTypes;
            result.ancestryPath = AncestryPath;
            result.isIncludeAbstractElements = IsIncludeAbstractElements;
            result.isIncludeExtendedElements = IsIncludeExtendedElements;
            result.isIncludeOnlyExtendedElements = IsIncludeOnlyExtendedElements;
            result.isMatchWholeWordsOnly = IsMatchWholeWordsOnly;
            result.textFieldsToSearch = textFieldsToSearch;
            result.isConvertPluralsToSingular = isConvertPluralsToSingular;
            result.sICPercentage = sICPercentage;
            result.sECPercentage = sECPercentage;
            result.includeSECPercentage = includeSECPercentage;
            result.includeSICPercentage = includeSICPercentage;

            return result;
        }
Exemple #16
0
 /// <summary>
 /// </summary>
 public ILibrarySearchResult Search(LibrarySearchCriteria criteria)
 {
     return(_indexMgr.Search(criteria));
 }
        public void IncludingExtendedElements_And_ExcludingExtendedElements()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .IncludingExtendedElements();

            Assert.IsTrue(crit.IsIncludeExtendedElements);

            crit.ExcludingExtendedElements();
            Assert.IsFalse(crit.IsIncludeExtendedElements);

            crit.IncludingExtendedElements();
            Assert.IsTrue(crit.IsIncludeExtendedElements);
        }
        public void Reset_With_Options_KeepPath()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithBalanceTypes(new Element.BalanceType[] { Element.BalanceType.credit, Element.BalanceType.debit, Element.BalanceType.na })
                .WithOptionalWords("Blah blah")
                .WithRequiredWords("Blab blab")
                .DescendingFrom("Test/Path/Here");

            crit.Reset(LibrarySearchCriteriaResetOptions.Full.WithKeepPath());

            Assert.AreEqual(new Element.BalanceType[]{}, crit.BalanceTypes);
            Assert.AreEqual(new string[]{}, crit.OptionalWords);
            Assert.AreEqual(new string[]{}, crit.RequiredWords);
            Assert.AreEqual("Test/Path/Here", crit.AncestryPath);
        }
        public void IncludeExtendedElements()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .SetIncludeExtendedElements(true);

            Assert.IsTrue(crit.IsIncludeExtendedElements);

            crit.SetIncludeExtendedElements(false);
            Assert.IsFalse(crit.IsIncludeExtendedElements);

            crit.SetIncludeExtendedElements(true);
            Assert.IsTrue(crit.IsIncludeExtendedElements);
        }
 private static void AssertFullResetState(LibrarySearchCriteria crit)
 {
     Assert.AreEqual(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels, LibrarySearchCriteria.SearchableTextField.Definitions }, crit.TextFieldsToSearch, "Post-reset TextFieldsToSearch");
     Assert.AreEqual(new Element.BalanceType[] { }, crit.BalanceTypes, "Post-reset BalanceTypes");
     Assert.AreEqual(new string[] { }, crit.ProhibitedWords, "Post-reset WithoutWords");
     Assert.AreEqual(new string[] { }, crit.OptionalWords, "Post-reset OneOrMoreWords");
     Assert.AreEqual(new string[] { }, crit.RequiredWords, "Post-reset AllWords");
     Assert.AreEqual(true, crit.IsIncludeAbstractElements, "Post-reset IsIncludeAbstractElements");
     Assert.AreEqual(true, crit.IsIncludeExtendedElements, "Post-reset IsIncludeExtendedElements");
     Assert.IsNull(crit.AncestryPath, "Pre-reset AncestryPath");
 }
        public void WithoutWordsSeparatedBySpace_Clears_And_Adds_Range()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithProhibitedWords("Joey");

            Assert.AreEqual(new string[] { "Joey" }, crit.ProhibitedWords);

            crit.WithProhibitedWords("Lawrence");

            Assert.AreEqual(new string[] { "Lawrence" }, crit.ProhibitedWords);
        }
        public void WithOneOrMoreWordsSeparatedBySpace_Clears_And_Adds_Range()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithOptionalWords("Joey");

            Assert.AreEqual(new string[] { "Joey" }, crit.OptionalWords);

            crit.WithOptionalWords("Lawrence");

            Assert.AreEqual(new string[] { "Lawrence" }, crit.OptionalWords);
        }
        public void WithBalanceTypes_Clears_And_Adds_Range()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithBalanceTypes(new Element.BalanceType[] {Element.BalanceType.credit});

            Assert.AreEqual(new Element.BalanceType[] { Element.BalanceType.credit }, crit.BalanceTypes);

            crit.WithBalanceTypes(new Element.BalanceType[] { Element.BalanceType.debit });

            Assert.AreEqual(new Element.BalanceType[] { Element.BalanceType.debit }, crit.BalanceTypes);
        }
        public void Search_Filters_BalanceType()
        {
            LibrarySearchCriteria criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels })
                .WithBalanceTypes(new Element.BalanceType[] { Element.BalanceType.credit});
            ILibrarySearchResult resultCredit = _indexMgr.Search(criteria);

            criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels })
                .WithBalanceTypes(new Element.BalanceType[] { Element.BalanceType.debit });
            ILibrarySearchResult resultDebit = _indexMgr.Search(criteria);

            Assert.AreEqual(4, resultCredit.Count, "hit count for credit balance type");
            Assert.AreEqual(16, resultDebit.Count, "hit count for debit balance type");
        }
        public void Search_Filters_RequiredWords()
        {
            LibrarySearchCriteria criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash")
                .MatchingPartialWords()
                .WithRequiredWords("Dividend")
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels });

            ILibrarySearchResult result = _indexMgr.Search(criteria);

            Assert.IsNotNull(result, "Search results should not be null");
            Assert.AreEqual(13, result.Count);

            foreach (ILibrarySearchResultItem hit in result.Items)
            {
                Assert.IsTrue(hit.Label.Contains("Cash"), "Hit with Label '" + hit.Label + "' does not contain 'Cash'");
                Assert.IsTrue(hit.Label.Contains("Dividend"), "Hit with Label '" + hit.Label + "' does not contain 'Dividend'");
            }
        }
        public void Search()
        {
            LibrarySearchCriteria criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash");

            ILibrarySearchResult result = _indexMgr.Search(criteria);

            Assert.IsNotNull(result, "Search results should not be null");
            Assert.AreEqual(143,result.Count);
        }
        public void Reset_With_Options_Full()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .WithBalanceTypes(new Element.BalanceType[] { Element.BalanceType.credit, Element.BalanceType.debit, Element.BalanceType.na })
                .WithOptionalWords("Blah blah")
                .WithRequiredWords("Blab blab")
                .DescendingFrom("Test/Path/Here");

            crit.Reset(LibrarySearchCriteriaResetOptions.Full);

            AssertFullResetState(crit);
        }
        public void Search_Filters_Extended()
        {
            //Bad test case...this taxonomy has no extended elements...

            LibrarySearchCriteria criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash")
                .IncludingExtendedElements();
            ILibrarySearchResult resultWith = _indexMgr.Search(criteria);

            criteria = new LibrarySearchCriteria()
                .WithOptionalWords("Cash")
                .ExcludingExtendedElements();
            ILibrarySearchResult resultWithout = _indexMgr.Search(criteria);

            Assert.AreEqual(143, resultWith.Count, "hit count INCLUDING extended elements in results");
            Assert.AreEqual(143, resultWithout.Count, "hit count EXCLUDING extended elements in results");
        }
        public void DescendingFrom()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .DescendingFrom("A/Path/Here");

            Assert.AreEqual("A/Path/Here", crit.AncestryPath);
        }
        public void Search_With_No_Search_Fields_Selected_Returns_A_Zero_Hits_Result()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .MatchingWholeWords()
                .WithOptionalWords("Joe")
                .IncludingExtendedElements()
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { });

            ILibrarySearchResult result = _indexMgr.Search(crit);

            Assert.AreEqual(0, result.Count, "Num results");
        }
Exemple #31
0
 /// <summary>
 /// </summary>
 public ILibrarySearchResult Search(LibrarySearchCriteria criteria)
 {
     return _indexMgr.Search(criteria);
 }
        public void ReIndexNode_Replaces_Old_Document()
        {
            Node node = GetNodeProvider().GetNodesForIndexing()[2];

            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .MatchingWholeWords()
                .WithOptionalWords(node.Id)
                .IncludingExtendedElements()
                .IncludingAbstractElements()
                .AgainstTextFields(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.ElementId });

            ILibrarySearchResult result = _indexMgr.Search(crit);

            Assert.AreEqual(1,result.Count, "TEST SANITY: There should only be one result");
            Assert.AreEqual(node.Label,result.Items[0].Label, "TEST SANITY: Node label should match the result label");

            string oldLabel = node.Label;
            string newLabel = oldLabel + " UNIT TEST";

            node.Label = newLabel;

            _indexMgr.ReIndexNode(node);

            ILibrarySearchResult result2 = _indexMgr.Search(crit);

            Assert.AreEqual(1, result2.Count, "There should only be one result");
            Assert.AreEqual(newLabel, result2.Items[0].Label, "The result label should match the new node label");

            //Reset the index for other tests
            node.Label = oldLabel;
            _indexMgr.ReIndexNode(node);
        }
        public void Reset()
        {
            LibrarySearchCriteria crit = new LibrarySearchCriteria()
                .AddTextFieldToSearch(LibrarySearchCriteria.SearchableTextField.Names)
                .AddBalanceType(Element.BalanceType.na)
                .AddProhibitedWord("Crapburger")
                .AddOptionalWord("Cheeseburger")
                .AddRequiredWord("Now")
                .ExcludingAbstractElements()
                .ExcludingExtendedElements()
                .MatchingWholeWords()
                .DescendingFrom("A/Path/Right/Here");

            Assert.AreEqual(new LibrarySearchCriteria.SearchableTextField[] { LibrarySearchCriteria.SearchableTextField.Labels, LibrarySearchCriteria.SearchableTextField.Definitions, LibrarySearchCriteria.SearchableTextField.Names }, crit.TextFieldsToSearch, "Pre-reset TextFieldsToSearch");
            Assert.AreEqual(new Element.BalanceType[] { Element.BalanceType.na }, crit.BalanceTypes, "Pre-reset BalanceTypes");
            Assert.AreEqual(new string[] { "Crapburger" }, crit.ProhibitedWords, "Pre-reset WithoutWords");
            Assert.AreEqual(new string[] { "Cheeseburger" }, crit.OptionalWords, "Pre-reset OneOrMoreWords");
            Assert.AreEqual(new string[] { "Now" }, crit.RequiredWords, "Pre-reset AllWords");
            Assert.AreEqual(false, crit.IsIncludeAbstractElements, "Pre-reset IsIncludeAbstractElements");
            Assert.AreEqual(false, crit.IsIncludeExtendedElements, "Pre-reset IsIncludeExtendedElements");
            Assert.AreEqual("A/Path/Right/Here", crit.AncestryPath, "Pre-reset AncestryPath");

            crit.Reset();
            AssertFullResetState(crit);
        }