private List<Developer> SimpleSearch(ProfileMatchConfig config, string[] queries) {
            List<Developer> searchResult = new List<Developer>();
            int sed = config.no_of_sed;
            int ned = config.no_of_ned;
            int fd = config.no_of_fd;
            foreach (var query in queries)
            {
                if (sed <= 0 && ned <= 0 && fd <= 0)
                {
                    break;
                }
                if (queries[0] == "General") {
                    int a = 0;
                }
                SearchResultCollection Results = searchManager.Search(query, 0, 1000, Searchable.AnalyzedFields.Values.ToArray());
              
                foreach (var result in Results.Data)
                {
                    result.Parse(x =>
                    {
                        result.Name = x.Get(Searchable.FieldStrings[Searchable.Field.Name]).Trim();
                        result.Product = x.Get(Searchable.FieldStrings[Searchable.Field.Product]);
                        result.Component = x.Get(Searchable.FieldStrings[Searchable.Field.Component]);
                        result.Skill = x.Get(Searchable.FieldStrings[Searchable.Field.Skill]);
                        result.DeveloperType = int.Parse(x.Get(Searchable.FieldStrings[Searchable.Field.DeveloperType]));
                    });
                    if (ned > 0 && result.DeveloperType == 2) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        ned--;
                        continue;
                    }
                    if (fd > 0 && result.DeveloperType == 3) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        fd--;
                        continue;
                    }
                    if (sed > 0 && result.DeveloperType == 1) {
                        searchResult.Add(new Developer { DeveloperName = result.Name, DeveloperId = result.DeveloperType });
                        sed--;
                        continue;
                    }
                   
                   
                  

                }
            }

             var finalResultset = searchResult.GroupBy(x => x.DeveloperName).Select(s => new Developer
                {
                    DeveloperName = s.Key,
                    DeveloperId = s.Select(x => x.DeveloperId).FirstOrDefault(),
                    current_workload = s.Select(x => x.DeveloperName).Count()
                }).OrderByDescending(x => x.current_workload).ToList();
            return finalResultset;
        }
Beispiel #2
0
        private void SearchCommand_Execute(object obj)
        {
            var documentDataList = _searchManager.Search(SearchString);

            SearchResultsCollection.Clear();

            foreach (var docData in documentDataList)
            {
                SearchResultsCollection.Add(docData);
            }
        }
        public ScalarTests()
        {
            _idProvider = new IdProvider();
            _testData = TestHelper.GetResponseData<Widget>(10);

            _searchManager = Substitute.For<ISearchManager>();
            _searchManager.Search(Arg.Any<AdvancedSearchCriteria>()).ReturnsForAnyArgs(
                _testData
                );

            _widgets = EktronQueryFactory.Queryable<Widget>(_idProvider, _searchManager);
        }
Beispiel #4
0
        //public async Task<IActionResult> Index()
        //{
        //    var pageViewModels = await _pageService.GetAllAsync();

        //    _searchManager.AddToIndex(pageViewModels.ToArray());

        //    return View();
        //}

        public IActionResult SearchResult(string term)
        {
            if (string.IsNullOrWhiteSpace(term))
            {
                return(View("Searching", new List <LuceneSearchModel>()));
            }

            var res = _searchManager.Search(term, new[] { "Title", "BriefDescription", "Body" });

            ViewBag.SearchTerm = "'" + term + "'";

            return(View("Searching", res.Where(p => p.IsShow)));
        }
        private void SearchCommand_Execute(object obj)
        {
            //LucceneTest test = new LucceneTest();
            //test.BuildIndex();
            //var res = test.Search(SearchString);
            //MessageBox.Show(res);

            if (string.IsNullOrEmpty(SearchString))
            {
                return;
            }

            var documentDataList = _searchManager.Search(
                new SearchContext
            {
                SearchString             = SearchString,
                IndexPath                = ConfigurationManager.AppSettings["IndexLocation"],
                ScanPath                 = ConfigurationManager.AppSettings["DataLocation"],
                SelectedSearchFilterData = SelectedSearchFilter
            });

            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                SearchResultsCollection?.Clear();

                if (documentDataList != null)
                {
                    SearchCount = documentDataList.Count;
                }

                foreach (var docData in documentDataList)
                {
                    SearchResultsCollection.Add(docData);
                }
            });

            //_synchronizationContext.Send((t) =>
            //{
            //    SearchResultsCollection?.Clear();

            //    if (documentDataList != null)
            //        SearchCount = documentDataList.Count;

            //    foreach (var docData in documentDataList)
            //    {
            //        SearchResultsCollection.Add(docData);
            //    }
            //}, null);
        }
Beispiel #6
0
        public List <Transaction> GetWithoutCategory(string keyword)
        {
            if (keyword.IsEmpty())
            {
                return(Provider.GetWithoutCategory().ToList());
            }

            var request = new SearchRequest()
            {
                Query = keyword, IsWildCardSearch = true
            };
            var response = searchManager.Search(request);

            return(Provider.GetWithoutCategory(response.Results.Select(i => new Guid(i.Id)).ToArray()));
        }
    private List <ContentType <Attraction> > populateMerchandise(string title, int paging)
    {
        //  IntegerPropertyExpression sfid = new IntegerPropertyExpression(smartFormID);
        //  id = current page id to exclude from query results
        //  parameters = current page query string
        //  title = title of current page
        //  contentBlockId = id of content block on current page to exclude from query results

        IEnumerable <QueryResult> results  = new List <QueryResult>();
        KeywordSearchCriteria     criteria = new KeywordSearchCriteria();

        criteria.QueryText   = title;
        criteria.ImplicitAnd = false;
        criteria.OrderBy     = new List <OrderData>()
        {
            new OrderData(SearchContentProperty.Rank, OrderDirection.Descending)
        };

        criteria.ExpressionTree =
            QueryProperties.Id > 0 &
            QueryProperties.SFID.EqualTo(9);
        criteria.PagingInfo             = new PagingInfo(paging);
        criteria.PagingInfo.CurrentPage = 1;
        criteria.ReturnProperties       = new HashSet <PropertyExpression>()
        {
            SearchContentProperty.Id,
            SearchContentProperty.Title,
            SearchContentProperty.QuickLink,
            SearchContentProperty.Description
        };

        ISearchManager manager = ObjectFactory.GetSearchManager();

        SearchResponseData response = manager.Search(criteria);
        List <ContentType <Attraction> > merchandiseList = new List <ContentType <Attraction> >();

        if (response.Results.Count > 0)
        {
            results = GetResults(response);
            foreach (Content.QueryResult merchandise in results)
            {
                ContentTypeManager <Attraction> contentTypeManagerAttraction = new ContentTypeManager <Attraction>();
                ContentType <Attraction>        cd = contentTypeManagerAttraction.GetItem(merchandise.Id);
                merchandiseList.Add(cd);
            }
        }
        return(merchandiseList);
    }
    private IEnumerable <QueryResult> populateRelatedContent(long id, QueryParams parameters, string title, long contentBlockId, int paging)
    {
        //  IntegerPropertyExpression sfid = new IntegerPropertyExpression(smartFormID);
        //  id = current page id to exclude from query results
        //  parameters = current page query string
        //  title = title of current page
        //  contentBlockId = id of content block on current page to exclude from query results

        IEnumerable <QueryResult> results  = new List <QueryResult>();
        KeywordSearchCriteria     criteria = new KeywordSearchCriteria();

        criteria.QueryText = title;
        criteria.OrderBy   = new List <OrderData>()
        {
            new OrderData(SearchContentProperty.Rank, OrderDirection.Descending)
        };

        criteria.ExpressionTree =
            QueryProperties.Id > 0 &
            QueryProperties.Id != contentBlockId &
            QueryProperties.Id != id&
            QueryProperties.SFID.NotEqualTo(10) &
            QueryProperties.SFID.NotEqualTo(9);

        criteria.PagingInfo             = new PagingInfo(paging);
        criteria.PagingInfo.CurrentPage = 1;
        criteria.ReturnProperties       = new HashSet <PropertyExpression>()
        {
            SearchContentProperty.Id,
            SearchContentProperty.Title,
            SearchContentProperty.QuickLink,
            SearchContentProperty.Description
        };

        ISearchManager manager = ObjectFactory.GetSearchManager();

        SearchResponseData response = manager.Search(criteria);

        if (response.Results.Count > 0)
        {
            results = GetResults(response);
        }
        return(results);
    }
Beispiel #9
0
        public HttpResponseMessage Search(HttpRequestMessage request, [FromUri] string term, [FromUri] int?location)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                Ad[] searchResults = searchManager.Search(term, location);

                foreach (var ad in searchResults)
                {
                    ad.IconClass = categoryRepository.Get(ad.CategoryId).IconClass;
                    ad.CategoryName = categoryRepository.Get(ad.CategoryId).CategoryCName;
                }

                response = request.CreateResponse(HttpStatusCode.OK, searchResults);

                return response;
            }));
        }
        public async Task <IActionResult> Index(string searchText)
        {
            if (string.IsNullOrWhiteSpace(searchText))
            {
                return(View());
            }

            var request = new SearchRequest()
            {
                SearchText = searchText
            };
            await _context.SearchRequests.AddAsync(request);

            await _context.SaveChangesAsync();

            var res = _searchManager.Search(searchText);

            if (!res.IsOk || res.Value == null)
            {
                _logger.LogInformation(res.ErrorMessage);
                return(View("Index", new SearchResponseDto()
                {
                    HasError = true,
                    Error = res.ErrorMessage
                }));
            }

            res.Value.SearchRequestId = request.Id;
            await _context.SearchResponses.AddAsync(res.Value);

            await _context.SaveChangesAsync();

            var resultDto    = _mapper.Map <SearchResponseDto>(res.Value);
            var searchSystem = await _context.SearchSystems.FindAsync(res.Value?.SearchSystemId);

            resultDto.SearchSystem = searchSystem?.SystemName ?? resultDto.SearchSystem;

            return(View("Index", resultDto));
        }
 public SmartSearchResponse Get(SmartSearchRequest searchRequest)
 {
     return(_searchManager.Search(searchRequest));
 }
Beispiel #12
0
        public IActionResult MainSearch(string searchValue, string showby = nameof(SearchType.MostRelevant))
        {
            if (string.IsNullOrWhiteSpace(searchValue))
            {
                return(View(new SearchResultsViewModel()
                {
                    SearchValue = string.Empty,
                    SearchType = SearchType.MostRelevant
                }));
            }
            var model = new SearchResultsViewModel()
            {
                SearchValue = searchValue.ToLower(),
                SearchType  = SearchType.MostRelevant
            };
            var allResults = new PriorityQueue <object>();

            switch (showby)
            {
            case nameof(SearchType.MostRelevant):
                allResults       = _searchManager.Search(searchValue.Trim().ToLower(), SearchType.MostRelevant);
                model.SearchType = SearchType.MostRelevant;
                break;

            case nameof(SearchType.SongName):
                allResults       = _searchManager.Search(searchValue.Trim().ToLower(), SearchType.SongName);
                model.SearchType = SearchType.SongName;
                break;

            case nameof(SearchType.Lyrics):
                allResults       = _searchManager.Search(searchValue.Trim().ToLower(), SearchType.Lyrics);
                model.SearchType = SearchType.Lyrics;
                break;

            case nameof(SearchType.ArtistName):
                allResults       = _searchManager.Search(searchValue.Trim().ToLower(), SearchType.ArtistName);
                model.SearchType = SearchType.ArtistName;
                break;

            case nameof(SearchType.RecordLabelName):
                allResults       = _searchManager.Search(searchValue.Trim().ToLower(), SearchType.RecordLabelName);
                model.SearchType = SearchType.RecordLabelName;
                break;
            }
            int toTake = 0;

            if (allResults.Count > MBoxConstants.initialTakeHomeLists)
            {
                toTake = MBoxConstants.initialTakeHomeLists;
            }
            else
            {
                toTake = allResults.Count;
            }

            for (int i = 0; i < toTake; i++)
            {
                model.Results.Enqueue(allResults.Peek(), allResults.PeekPriority());
                allResults.Dequeue();
            }
            return(View(model));
        }