Beispiel #1
0
        public void IndexContent(IndexWriter indexWriter, JobAdSearchContent content, bool isNew)
        {
            var document = new Document();

            // ID

            var id      = content.JobAd.Id.ToFieldValue();
            var idField = new Field(SearchFieldName.Id, id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);

            idField.setOmitTermFreqAndPositions(true);
            document.add(idField);

            // Handlers.

            _contentHandler.AddContent(document, content);
            _locationHandler.AddContent(document, content);
            _salaryHandler.AddContent(document, content);
            _industryHandler.AddContent(document, content);
            _jobTypesHandler.AddContent(document, content);
            _createdTimeHandler.AddContent(document, content);
            _communityHandler.AddContent(document, content);
            _featuredHandler.AddContent(document, content);

            // Save the document.

            if (isNew)
            {
                indexWriter.addDocument(document, _contentAnalyzer);
            }
            else
            {
                indexWriter.updateDocument(new Term(SearchFieldName.Id, id), document, _contentAnalyzer);
            }
        }
Beispiel #2
0
        public void IndexContent(IndexWriter indexWriter, ResourceContent content, bool isNew)
        {
            var document = new Document();

            // ID

            var id      = content.Resource.Id.ToFieldValue();
            var idField = new Field(SearchFieldName.Id, id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);

            idField.setOmitTermFreqAndPositions(true);
            document.add(idField);

            // Handlers.

            _contentHandler.AddContent(document, content);
            _itemTypeHandler.AddContent(document, content);
            _subcategoryHandler.AddContent(document, content);
            _createdTimeHandler.AddContent(document, content);
            _popularityHandler.AddContent(document, content);

            // Save the document.

            if (isNew)
            {
                indexWriter.addDocument(document, _contentAnalyzer);
            }
            else
            {
                indexWriter.updateDocument(new Term(SearchFieldName.Id, id), document, _contentAnalyzer);
            }
        }
Beispiel #3
0
        public void IndexContent(IndexWriter indexWriter, MemberContent content, bool isNew)
        {
            if (EventSource.IsEnabled(Event.Trace))
            {
                EventSource.Raise(Event.Trace, Method, "Adding Content.", Event.Arg("member", content.Member.Id));
            }

            var document   = new Document();
            var docBuilder = new BoostingDocumentBuilder(_contentAnalyzer);

            // Id.

            var id      = content.Member.Id.ToFieldValue();
            var idField = new Field(SearchFieldName.Id, id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);

            idField.setOmitTermFreqAndPositions(true);
            document.add(idField);

            // Handlers.

            _contentHandler.AddContent(document, docBuilder, content);
            _lastUpdatedHandler.AddContent(document, content);
            _desiredJobTypesHandler.AddContent(document, content);
            _candidateStatusHandler.AddContent(document, content);
            _ethnicStatusHandler.AddContent(document, content);
            _visaStatusHandler.AddContent(document, content);
            _industryHandler.AddContent(document, content);
            _communityHandler.AddContent(document, content);
            _salaryHandler.AddContent(document, content);
            _locationHandler.AddContent(document, content);
            _nameHandler.AddContent(document, content);
            _hasResumeHandler.AddContent(document, content);
            _isActivatedHandler.AddContent(document, content);
            _isContactableHandler.AddContent(document, content);

            // Save the document.

            docBuilder.CopyTo(document);
            if (isNew)
            {
                indexWriter.addDocument(document, _contentAnalyzer);
            }
            else
            {
                indexWriter.updateDocument(new Term(SearchFieldName.Id, id), document, _contentAnalyzer);
            }

            if (EventSource.IsEnabled(Event.Trace))
            {
                EventSource.Raise(Event.Trace, Method, string.Format("Content {0}.", isNew ? "Added" : "Updated"), Event.Arg("member", content.Member.Id), Event.Arg("lastupdate date", new[] { content.Member.LastUpdatedTime, content.Candidate.LastUpdatedTime, content.Resume == null ? DateTime.MinValue : content.Resume.LastUpdatedTime }.Max()), Event.Arg("document date", document.getValues(FieldName.LastUpdatedDay)));
            }
        }