Beispiel #1
0
 public IEnumerable <BrowseSelection> GetSelections(JobAdSearchQuery query)
 {
     return(from h in _handlers
            let s = h.GetSelection(query)
                    where s != null
                    select s);
 }
Beispiel #2
0
        public LuceneSort GetSort(IMember member, JobAdSearchQuery searchQuery)
        {
            switch (searchQuery.SortOrder)
            {
            case JobAdSortOrder.Relevance:

                // Default sort.

                return(null);

            case JobAdSortOrder.CreatedTime:
                return(_createdTimeHandler.GetSort(searchQuery));

            case JobAdSortOrder.JobType:
                return(_jobTypesHandler.GetSort(searchQuery));

            case JobAdSortOrder.Distance:
                return(_locationHandler.GetSort(searchQuery));

            case JobAdSortOrder.Salary:
                return(_salaryHandler.GetSort(searchQuery));

            case JobAdSortOrder.Flagged:
                return(new LuceneSort(new[]
                {
                    new BoboCustomSortField(SearchFieldName.Id, !searchQuery.ReverseSortOrder, new SpecialsComparatorSource(false, _jobAdFlagListsQuery.GetFlaggedJobAdIds(member).Select(id => id.ToFieldValue()), SearchFieldName.Id)), SortField.FIELD_SCORE
                }));

            default:
                return(null);
            }
        }
        LuceneFilter IContentHandler.GetFilter(JobAdSearchQuery searchQuery)
        {
            // If the community is not set then only include non-community jobs.

            if (!searchQuery.CommunityId.HasValue)
            {
                var filter = new TermsFilter();
                filter.addTerm(new Term(FieldName.HasCommunity, HasNoCommunityId));
                return(filter);
            }

            // The community is set so it needs to be included.

            var specificCommunityFilter = new TermsFilter();

            specificCommunityFilter.addTerm(new Term(FieldName.Community, searchQuery.CommunityId.Value.ToFieldValue()));

            // If it is only the community that must be returned then return it.

            if (searchQuery.CommunityOnly.HasValue && searchQuery.CommunityOnly.Value)
            {
                return(specificCommunityFilter);
            }

            // Need to include those that match the community, or have no community set, i.e. all other community jobs should not be retutned.

            var noCommunityFilter = new TermsFilter();

            noCommunityFilter.addTerm(new Term(FieldName.HasCommunity, HasNoCommunityId));

            return(new ChainedFilter(new Filter[] { specificCommunityFilter, noCommunityFilter }, ChainedFilter.OR));
        }
Beispiel #4
0
        public void TestIndustry()
        {
            var accounting     = _industriesQuery.GetIndustry("Accounting");
            var administration = _industriesQuery.GetIndustry("Administration");
            var construction   = _industriesQuery.GetIndustry("Construction");
            var other          = _industriesQuery.GetIndustry("Other");

            // One each in each industry.

            var jobAd0 = CreateJobAd(0, accounting);

            IndexJobAd(jobAd0, "LinkMe");

            var jobAd1 = CreateJobAd(0, administration);

            IndexJobAd(jobAd1, "LinkMe");

            // One in all.

            var jobAd2 = CreateJobAd(0, accounting, administration, construction);

            IndexJobAd(jobAd2, "LinkMe");

            // One in none.

            var jobAd3 = CreateJobAd(0);

            IndexJobAd(jobAd3, "LinkMe");

            // Search.

            var jobQuery = new JobAdSearchQuery();

            AssertJobAds(Search(jobQuery), jobAd0, jobAd1, jobAd2, jobAd3);

            jobQuery.IndustryIds = new[] { accounting.Id };
            AssertJobAds(Search(jobQuery), jobAd0, jobAd2);

            jobQuery.IndustryIds = new[] { administration.Id };
            AssertJobAds(Search(jobQuery), jobAd1, jobAd2);

            jobQuery.IndustryIds = new[] { construction.Id };
            AssertJobAds(Search(jobQuery), jobAd2);

            jobQuery.IndustryIds = new[] { other.Id };
            AssertJobAds(Search(jobQuery), jobAd3);

            jobQuery.IndustryIds = new[] { accounting.Id, administration.Id };
            AssertJobAds(Search(jobQuery), jobAd0, jobAd1, jobAd2);

            jobQuery.IndustryIds = new[] { accounting.Id, administration.Id, construction.Id };
            AssertJobAds(Search(jobQuery), jobAd0, jobAd1, jobAd2);

            jobQuery.IndustryIds = new[] { accounting.Id, administration.Id, other.Id };
            AssertJobAds(Search(jobQuery), jobAd0, jobAd1, jobAd2, jobAd3);

            jobQuery.IndustryIds = (from i in _industriesQuery.GetIndustries() select i.Id).ToList();
            AssertJobAds(Search(jobQuery), jobAd0, jobAd1, jobAd2, jobAd3);
        }
Beispiel #5
0
 JobAdSearchResults IJobAdSearchService.SearchFlagged(Guid?memberId, JobAdSearchQuery query)
 {
     return(Search(
                memberId,
                query,
                (m, q) => _jobAdActivityFiltersQuery.GetFlaggedIncludeJobAdIds(m, q),
                (m, q) => _jobAdActivityFiltersQuery.GetFlaggedExcludeJobAdIds(m, q)));
 }
Beispiel #6
0
        public LuceneQuery GetQuery(JobAdSearchQuery searchQuery)
        {
            var fieldQueries = CreateFieldQueries(searchQuery);
            var query        = fieldQueries.CombineQueries(BooleanClause.Occur.MUST) ?? new MatchAllDocsQuery();

            return(searchQuery.SortOrder == JobAdSortOrder.Relevance
                ? _booster.GetRecencyBoostingQuery(query)
                : query);
        }
Beispiel #7
0
 private LuceneQuery[] CreateFieldQueries(JobAdSearchQuery query)
 {
     return(new[]
     {
         GetContentQuery(query),
         GetTitleQuery(query),
         GetAdvertiserQuery(query)
     });
 }
Beispiel #8
0
        private JobAdSearchResults Search(Guid?memberId, JobAdSearchQuery searchQuery, Func <IMember, JobAdSearchQuery, IList <Guid> > getIncludeJobAdIds, Func <IMember, JobAdSearchQuery, IList <Guid> > getExcludeJobAdIds)
        {
            const string method = "Search";

            try
            {
                #region Log
                Stopwatch searchTime = null;
                if (EventSource.IsEnabled(Event.Trace))
                {
                    searchTime = Stopwatch.StartNew();
                }
                #endregion

                var member = memberId == null
                    ? null
                    : new Member {
                    Id = memberId.Value
                };

                var query      = _indexer.GetQuery(searchQuery);
                var filter     = _indexer.GetFilter(searchQuery, getIncludeJobAdIds(member, searchQuery), getExcludeJobAdIds(member, searchQuery));
                var sort       = _indexer.GetSort(member, searchQuery);
                var selections = _indexer.GetSelections(searchQuery);

                #region Log
                if (EventSource.IsEnabled(Event.Trace))
                {
                    EventSource.Raise(Event.Trace, method, "Executing query.", Event.Arg("query", query != null ? query.toString() : string.Empty));
                }
                #endregion

                var reader   = GetReader();
                var searcher = new Searcher(reader);
                var sorts    = sort != null?sort.getSort() : null;

                var searchResults = searcher.Search(query, filter, selections, sorts, searchQuery.Skip, searchQuery.Take ?? reader.maxDoc(), true);

                #region Log
                if (searchTime != null)
                {
                    searchTime.Stop();
                    EventSource.Raise(Event.Trace, method, "Query execution complete.", Event.Arg("query", (query != null) ? query.toString() : string.Empty), Event.Arg("total hits", searchResults.TotalMatches), Event.Arg("result count", searchResults.JobAdIds.Count), Event.Arg("searchTime", searchTime.ElapsedMilliseconds));
                }
                #endregion

                return(searchResults);
            }
            catch (Exception e)
            {
                #region Log
                EventSource.Raise(Event.Error, method, "Unexpected exception.", e);
                #endregion
                throw;
            }
        }
Beispiel #9
0
        LuceneFilter IContentHandler.GetFilter(JobAdSearchQuery searchQuery)
        {
            if (searchQuery.Recency == null)
            {
                return(null);
            }

            var modifiedSince = DateTime.Now - searchQuery.Recency.Value;

            return(GetFilter(modifiedSince));
        }
Beispiel #10
0
        public void TestFeatureBoost()
        {
            // Create job ads.

            var jobAd1 = CreateJobAd(JobAdFeatureBoost.Low, "Best Job in the World", new[] { "good verbal communication", "self management and independency", "good time management" });

            IndexJobAd(jobAd1, "LinkMe");

            var jobAd2 = CreateJobAd(JobAdFeatureBoost.None, "Not so good Job", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd2, "LinkMe");

            var jobAd3 = CreateJobAd(JobAdFeatureBoost.High, "Not so good Job", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd3, "LinkMe");

            var jobAd4 = CreateJobAd(JobAdFeatureBoost.None, "You really don't want this", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd4, "LinkMe");

            var jobAd5 = CreateJobAd(JobAdFeatureBoost.Low, "You really don't want this", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd5, "LinkMe");

            var jobAd6 = CreateJobAd(JobAdFeatureBoost.High, "You really don't want this", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd6, "LinkMe");

            // High should appear first in all queries.

            var jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Relevance, Keywords = Expression.Parse("good")
            };
            var results = Search(jobQuery);

            Assert.AreEqual(6, results.JobAdIds.Count);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd6.Id, results.JobAdIds[2]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[3]);
            Assert.AreEqual(jobAd5.Id, results.JobAdIds[4]);
            Assert.AreEqual(jobAd4.Id, results.JobAdIds[5]);

            // Limited query.

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Relevance, Keywords = Expression.Parse("really")
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd6.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd5.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd4.Id, results.JobAdIds[2]);
        }
Beispiel #11
0
        protected JobAdSearchResults Search(IMember member, JobAdSearchQuery jobAdQuery)
        {
            var reader   = _indexWriter.getReader();
            var searcher = new Searcher(reader);
            var query    = _indexer.GetQuery(jobAdQuery);
            var filter   = _indexer.GetFilter(
                jobAdQuery,
                _jobAdActivityFiltersQuery.GetIncludeJobAdIds(member, jobAdQuery),
                _jobAdActivityFiltersQuery.GetExcludeJobAdIds(member, jobAdQuery));
            var selections    = _indexer.GetSelections(jobAdQuery);
            var sort          = _indexer.GetSort(member, jobAdQuery);
            var searchResults = searcher.Search(query, filter, selections, sort == null ? null : sort.getSort(), jobAdQuery.Skip, jobAdQuery.Take ?? reader.maxDoc(), true);

            return(searchResults);
        }
Beispiel #12
0
        public BrowseSelection GetSelection(JobAdSearchQuery searchQuery)
        {
            /*
             * if (searchQuery.ExcludeIntegratorIds == null || searchQuery.ExcludeIntegratorIds.Count == 0)
             *  return null;
             *
             * var selection = new BrowseSelection(FieldName.Integrator);
             * foreach (var integratorId in searchQuery.ExcludeIntegratorIds)
             *  selection.addNotValue(integratorId.ToFieldValue());
             *
             * return selection;
             */

            return(null);
        }
Beispiel #13
0
        private ICollection <Guid> Filter(IMember member, JobAdSearchQuery query, IEnumerable <Guid> allJobAdIds)
        {
            var includeJobAdIds = _jobAdActivityFiltersQuery.GetIncludeJobAdIds(member, query);
            var jobAdIds        = includeJobAdIds != null
                                ? allJobAdIds.Intersect(includeJobAdIds)
                                : allJobAdIds;

            var excludeJobAdIds = _jobAdActivityFiltersQuery.GetExcludeJobAdIds(member, query);

            jobAdIds = excludeJobAdIds != null
                            ? jobAdIds.Except(excludeJobAdIds)
                            : jobAdIds;

            return(jobAdIds.ToArray());
        }
Beispiel #14
0
        public void TestCreatedTime()
        {
            var now = DateTime.Now;

            // Create jobAds.

            var jobAd1 = CreateJobAd(now.AddDays(-1), "Best Job in the World", new[] { "good verbal communication", "self management and independency", "good time management" });

            IndexJobAd(jobAd1, null);

            var jobAd2 = CreateJobAd(now.AddDays(-10), "Not so good Job", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd2, null);

            var jobAd3 = CreateJobAd(now.AddDays(-10), "You really don't want this", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd3, null);

            var jobAd4 = CreateJobAd(now.AddDays(-1), "You really don't want this", new[] { "good verbal communication", "self management and independency", "bullet point 3" });

            IndexJobAd(jobAd4, null);

            // 3 and 4 are equivalent but 4 should appear before 3 because it is featured.
            // 2 appears before 4 becuase it is a better match for the query.

            var jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Relevance, Keywords = Expression.Parse("good")
            };
            var results = Search(jobQuery);

            Assert.AreEqual(4, results.JobAdIds.Count);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd4.Id, results.JobAdIds[2]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[3]);

            // Limited query.

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Relevance, Keywords = Expression.Parse("really")
            };
            results = Search(jobQuery);
            Assert.AreEqual(2, results.JobAdIds.Count);
            Assert.AreEqual(jobAd4.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[1]);
        }
Beispiel #15
0
        public void TestSalary()
        {
            // At the moment this test is just checking that no exception is raised in these situations.

            var jobQuery = new JobAdSearchQuery();

            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = 0, UpperBound = 0, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = 0, UpperBound = null, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = null, UpperBound = 0, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = null, UpperBound = null, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = 50000, UpperBound = null, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = null, UpperBound = 50000, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));

            jobQuery.Salary = new Salary {
                LowerBound = 30000, UpperBound = 50000, Rate = SalaryRate.Year, Currency = Currency.AUD
            };
            AssertJobAds(Search(jobQuery));
        }
Beispiel #16
0
        public LuceneFilter GetFilter(JobAdSearchQuery searchQuery)
        {
            if (searchQuery.ExcludeIntegratorIds == null || searchQuery.ExcludeIntegratorIds.Count == 0)
            {
                return(null);
            }

            var termsFilter = new TermsFilter();

            foreach (var integratorId in searchQuery.ExcludeIntegratorIds)
            {
                termsFilter.addTerm(new Term(FieldName.Integrator, integratorId.ToFieldValue()));
            }

            var filter = new BooleanFilter();

            filter.add(new FilterClause(termsFilter, BooleanClause.Occur.MUST_NOT));

            return(filter);
        }
Beispiel #17
0
        public LuceneFilter GetFilter(JobAdSearchQuery query, IEnumerable <Guid> includeJobAdIds, IEnumerable <Guid> excludeJobAdIds)
        {
            var filters = (from h in _handlers
                           let f = h.GetFilter(query)
                                   where f != null
                                   select f).ToList();

            if (includeJobAdIds != null)
            {
                filters.Add(new SpecialsFilter(SearchFieldName.Id, false, includeJobAdIds.Select(id => id.ToFieldValue())));
            }

            if (excludeJobAdIds != null)
            {
                filters.Add(new SpecialsFilter(SearchFieldName.Id, true, excludeJobAdIds.Select(id => id.ToFieldValue())));
            }

            return(filters.Count == 0
                ? null
                : new ChainedFilter(filters.ToArray(), ChainedFilter.AND));
        }
Beispiel #18
0
 public LuceneQuery GetAdvertiserQuery(JobAdSearchQuery query)
 {
     return(query.AdvertiserName.GetLuceneQuery(query.IncludeSynonyms ? FieldName.AdvertiserName : FieldName.AdvertiserNameExact, _queryAnalyzer));
 }
Beispiel #19
0
 public LuceneQuery GetTitleQuery(JobAdSearchQuery query)
 {
     return(query.AdTitle.GetLuceneQuery(query.IncludeSynonyms ? FieldName.Title : FieldName.TitleExact, _queryAnalyzer));
 }
Beispiel #20
0
 public LuceneQuery GetContentQuery(JobAdSearchQuery query)
 {
     return(query.Keywords.GetLuceneQuery(query.IncludeSynonyms ? FieldName.Content : FieldName.ContentExact, _queryAnalyzer));
 }
 BrowseSelection IContentHandler.GetSelection(JobAdSearchQuery searchQuery)
 {
     return(GetSelection(searchQuery.IndustryIds));
 }
 LuceneSort IContentHandler.GetSort(JobAdSearchQuery searchQuery)
 {
     return(null);
 }
 LuceneFilter IContentHandler.GetFilter(JobAdSearchQuery searchQuery)
 {
     return(null);
 }
Beispiel #24
0
 LuceneSort IContentHandler.GetSort(JobAdSearchQuery searchQuery)
 {
     return(GetSort(searchQuery.ReverseSortOrder));
 }
Beispiel #25
0
 BrowseSelection IContentHandler.GetSelection(JobAdSearchQuery searchQuery)
 {
     return(null);
 }
Beispiel #26
0
        LuceneSort IContentHandler.GetSort(JobAdSearchQuery searchQuery)
        {
            // Reverse the natural order, i.e. newest at the top.

            return(GetSort(!searchQuery.ReverseSortOrder));
        }
Beispiel #27
0
        public void BasicSearchTest()
        {
            //Create jobAds

            var testIntegratorId = Guid.NewGuid();
            var australia        = _locationQuery.GetCountry("Australia");

            var jobAd1 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "Best Job in the World",
                Integration = { IntegratorUserId = testIntegratorId },
                CreatedTime = DateTime.Now,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Salary       = new Salary          {
                        LowerBound =     20000, UpperBound = 40000, Rate = SalaryRate.Year, Currency = Currency.AUD
                    },
                    Industries     = new List <Industry> {
                        _industriesQuery.GetIndustry("Consulting & Corporate Strategy")
                    },
                    Location       = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "VIC")),
                },
            };

            IndexJobAd(jobAd1, "LinkMe");

            var jobAd2 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "Not so good Job",
                CreatedTime = DateTime.Now,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Salary       = new Salary          {
                        LowerBound =     200000, UpperBound = 400000, Rate = SalaryRate.Year, Currency = Currency.AUD
                    },
                    Industries     = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                    Location       = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "NSW")),
                }
            };

            IndexJobAd(jobAd2, "LinkMe");

            var jobAd3 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "You really don't want this",
                Integration = { IntegratorUserId = testIntegratorId },
                CreatedTime = DateTime.Now,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Industries   = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                    Location     = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "QLD")),
                }
            };

            IndexJobAd(jobAd3, "LinkMe");

            // Search without filter.

            var jobQuery = new JobAdSearchQuery();
            var results  = Search(jobQuery);

            Assert.AreEqual(3, results.JobAdIds.Count);

            //Search for a salary range

            jobQuery = new JobAdSearchQuery
            {
                Salary = new Salary {
                    LowerBound = 10000, UpperBound = 30000, Rate = SalaryRate.Year, Currency = Currency.AUD
                }
            };
            results = Search(jobQuery);
            Assert.AreEqual(2, results.JobAdIds.Count);
            Assert.IsTrue(new[] { jobAd1.Id, jobAd3.Id }.CollectionEqual(results.JobAdIds));

            //Search for a salary range; exclude empty

            jobQuery = new JobAdSearchQuery
            {
                Salary = new Salary {
                    LowerBound = 10000, UpperBound = 30000, Rate = SalaryRate.Year, Currency = Currency.AUD
                },
                ExcludeNoSalary = true,
            };
            results = Search(jobQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[0]);

            //search on exact bullet point

            jobQuery = new JobAdSearchQuery
            {
                IncludeSynonyms = false,
                Keywords        = Expression.ParseExactPhrase("good verbal"),
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);

            //search on exact bullet point again with a phrase that doesn't exist

            jobQuery = new JobAdSearchQuery
            {
                IncludeSynonyms = false,
                Keywords        = Expression.ParseExactPhrase("bad verbal"),
            };
            results = Search(jobQuery);
            Assert.AreEqual(0, results.JobAdIds.Count);

            //search on bullet point with any words

            jobQuery = new JobAdSearchQuery
            {
                IncludeSynonyms = false,
                Keywords        = Expression.Parse("bad verbal", BinaryOperator.Or),
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);

            //search on bullet point with all words

            jobQuery = new JobAdSearchQuery
            {
                IncludeSynonyms = false,
                Keywords        = Expression.Parse("bad verbal", BinaryOperator.And),
            };
            results = Search(jobQuery);
            Assert.AreEqual(0, results.JobAdIds.Count);

            // search on industry

            jobQuery = new JobAdSearchQuery
            {
                IndustryIds = new List <Guid> {
                    _industriesQuery.GetIndustryByAnyName("Engineering").Id
                },
            };
            results = Search(jobQuery);
            Assert.AreEqual(2, results.JobAdIds.Count);
            Assert.IsTrue(new[] { jobAd2.Id, jobAd3.Id }.CollectionEqual(results.JobAdIds));

            // search on specific job title

            jobQuery = new JobAdSearchQuery {
                AdTitle = Expression.Parse("good job", BinaryOperator.Or)
            };
            results = Search(jobQuery);
            Assert.AreEqual(2, results.JobAdIds.Count);
            Assert.IsTrue(new[] { jobAd1.Id, jobAd2.Id }.CollectionEqual(results.JobAdIds));

            // search by location
            jobQuery = new JobAdSearchQuery {
                Location = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "QLD")), Distance = 50
            };
            results = Search(jobQuery);
            Assert.AreEqual(1, results.JobAdIds.Count);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[0]);

            // search by location with large distance to include neighbouring state
            jobQuery = new JobAdSearchQuery {
                Location = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "VIC")), Distance = 2000
            };
            results = Search(jobQuery);
            Assert.AreEqual(2, results.JobAdIds.Count);
            Assert.IsTrue(new[] { jobAd1.Id, jobAd2.Id }.CollectionEqual(results.JobAdIds));

            //search by minCreatedTime
            jobQuery = new JobAdSearchQuery {
                Recency = DateTime.Now - DateTime.Now.AddHours(-1)
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
        }
Beispiel #28
0
 public Sort GetSort(JobAdSearchQuery searchQuery)
 {
     return(null);
 }
Beispiel #29
0
 BrowseSelection IContentHandler.GetSelection(JobAdSearchQuery searchQuery)
 {
     return(GetSelection(searchQuery.JobTypes));
 }
Beispiel #30
0
        public void TestSort()
        {
            //Create jobAds

            var testIntegratorId = Guid.NewGuid();
            var australia        = _locationQuery.GetCountry("Australia");

            var jobAd1 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "Best Job in the World",
                Integration = { IntegratorUserId = testIntegratorId },
                CreatedTime = DateTime.Now.AddDays(-2),
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "good time management" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Salary       = new Salary          {
                        LowerBound =     20000, UpperBound = 40000, Rate = SalaryRate.Year, Currency = Currency.AUD
                    },
                    Industries     = new List <Industry> {
                        _industriesQuery.GetIndustry("Consulting & Corporate Strategy")
                    },
                    Location       = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "VIC")),
                },
            };

            IndexJobAd(jobAd1, "LinkMe");

            var jobAd2 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "Not so good Job",
                CreatedTime = DateTime.Now,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.Temp,
                    Salary       = new Salary          {
                        LowerBound =     200000, UpperBound = 400000, Rate = SalaryRate.Year, Currency = Currency.AUD
                    },
                    Industries     = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                    Location       = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "NSW")),
                }
            };

            IndexJobAd(jobAd2, "LinkMe");

            var jobAd3 = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = JobAdStatus.Open,
                Title       = "You really don't want this",
                Integration = { IntegratorUserId = testIntegratorId },
                CreatedTime = DateTime.Now.AddDays(-100),
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.PartTime,
                    Industries   = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                    Location     = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "QLD")),
                }
            };

            IndexJobAd(jobAd3, "LinkMe");

            // Sort by salary.

            var jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Salary
            };
            var results = Search(jobQuery);

            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[2]);

            // Sort by distance.

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Distance, Distance = 3000, Location = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "QLD"))
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[2]);

            // Sort by jobtype.

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.JobType
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[2]);

            // Sort by jobtype II.

            jobAd2.Description.JobTypes = JobTypes.All;
            IndexJobAd(jobAd2, "LinkMe", null, false);

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.JobType
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            //1 & 2 are equivalent - just make sure PT is last
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[2]);

            // Sort by jobtype III.

            jobAd1.Description.JobTypes |= JobTypes.Temp;
            IndexJobAd(jobAd1, "LinkMe", null, false);

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.JobType
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            //1 & 2 are equivalent - just make sure PT is last
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[2]);

            // Sort by jobtype IV.

            jobAd1.Description.JobTypes = JobTypes.Temp | JobTypes.Contract;
            IndexJobAd(jobAd1, "LinkMe", null, false);

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.JobType
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[2]);

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.JobType, ReverseSortOrder = true
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[2]);

            // Sort by flagged list.

            //TODO: no support for flagging jobads yet

            // sort by relevance

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.Relevance, Keywords = Expression.Parse("good")
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[2]);

            // Sort by createTime.

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.CreatedTime
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[2]);

            jobQuery = new JobAdSearchQuery {
                SortOrder = JobAdSortOrder.CreatedTime, ReverseSortOrder = true
            };
            results = Search(jobQuery);
            Assert.AreEqual(3, results.JobAdIds.Count);
            Assert.AreEqual(jobAd3.Id, results.JobAdIds[0]);
            Assert.AreEqual(jobAd1.Id, results.JobAdIds[1]);
            Assert.AreEqual(jobAd2.Id, results.JobAdIds[2]);
        }