Ejemplo n.º 1
0
        private IEnumerable <LinkInfo> GetTagLinks(string tag)
        {
            var tagDocs = mIndexReader.TermDocs(new Term(FIELD_TAG, tag));
            var urlAndCaptionSelector = new Lucene.Net.Documents.MapFieldSelector(FIELD_URL, FIELD_CAPTION);

            while (tagDocs.Next())
            {
                var tagDocument = mIndexReader.Document(tagDocs.Doc, urlAndCaptionSelector);
                if (tagDocument != null)
                {
                    var fieldUrl     = tagDocument.GetField(FIELD_URL);
                    var fieldCaption = tagDocument.GetField(FIELD_CAPTION);
                    if (fieldUrl != null && !string.IsNullOrEmpty(fieldUrl.StringValue))
                    {
                        yield return(new
                                     LinkInfo
                        {
                            Url = fieldUrl.StringValue,
                            Caption = fieldCaption != null ? fieldCaption.StringValue : string.Empty
                        });
                    }
                }
            }
            yield break;
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="index">Parent Lucene index.</param>
            internal FileList(LuceneIndex index)
            {
                mIndex = index;

                // This gets a little complicated, as the tag documents are also part of the index an can be inbetween the source code documents and
                // therfore they must be skipped...
                // So we build up an index-to-docid mapping first and need to subtract the number of tag documents from the total number of documents
                // to get the actual number of files.
                int numTagDocs = BuildIndexToDocIdMap(mIndex.mIndexReader, out mIndexToDocIdMapping);

                mCount = mIndex.mIndexReader.NumDocs() - numTagDocs;

                mPathSelector = new Lucene.Net.Documents.MapFieldSelector(FIELD_PATH);
            }