コード例 #1
0
        public async Task <List <DocumentModel> > MultiSearch(IndexModel indexModel, MultiSearchModel searchModel)
        {
            var results = new List <List <DocumentModel> >();

            foreach (var search in searchModel.Searches)
            {
                SetSearcher(search.Type);
                results.Add(await _searcher.ExecuteSearch(indexModel, search));
            }

            List <DocumentModel> searchResult;

            switch (searchModel.QueryType)
            {
            case QueryType.Or:
                searchResult = CollectionsHelper.Union(new DocumentComparer(), results.ToArray()).ToList();
                break;

            case QueryType.And:
                searchResult = CollectionsHelper.Intersect(new DocumentComparer(), results.ToArray()).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(GetSorted(searchModel, searchResult));
        }
コード例 #2
0
        public void IntersectTest()
        {
            var arr1 = new[] { "1", "23", "11", "32" };
            var arr2 = new[] { "2", "23", "41", "32" };
            var arr3 = new[] { "13", "23", "113", "31" };
            var arr4 = new[] { "112", "23", "111", "312" };

            var actual = CollectionsHelper.Intersect(null, arr1, arr2, arr3, arr4).ToArray();

            Assert.IsNotEmpty(actual);
            Assert.AreEqual("23", actual.First());
        }
コード例 #3
0
        public void IntersectDocumentTest()
        {
            var arr  = Datas.Data.SetData(new IndexModel("", ""));
            var arr1 = new List <DocumentModel> {
                arr[5], arr[6]
            };
            var arr2 = new List <DocumentModel> {
                arr[6]
            };

            var actual = CollectionsHelper.Intersect(null, (new List <List <DocumentModel> > {
                arr1, arr2
            }).ToArray()).ToList();

            Assert.IsNotEmpty(actual);
        }