コード例 #1
0
        /// <summary> Adds a document to this index, using the provided analyzer instead of the
        /// value of {@link #GetAnalyzer()}.  If the document contains more than
        /// {@link #SetMaxFieldLength(int)} terms for a given field, the remainder are
        /// discarded.
        /// </summary>
        public virtual void  AddDocument(Document doc, Analyzer analyzer)
        {
            DocumentWriter dw = new DocumentWriter(ramDirectory, analyzer, this);

            dw.SetInfoStream(infoStream);
            System.String segmentName = NewSegmentName();
            dw.AddDocument(segmentName, doc);
            lock (this)
            {
                segmentInfos.Add(new SegmentInfo(segmentName, 1, ramDirectory));
                MaybeMergeSegments();
            }
        }
コード例 #2
0
ファイル: DocHelper.cs プロジェクト: yonder/mono
        /// <summary> Writes the document to the directory segment using the analyzer and the similarity score</summary>
        /// <param name="">dir
        /// </param>
        /// <param name="">analyzer
        /// </param>
        /// <param name="">similarity
        /// </param>
        /// <param name="">segment
        /// </param>
        /// <param name="">doc
        /// </param>
        public static void  WriteDoc(Directory dir, Analyzer analyzer, Similarity similarity, System.String segment, Document doc)
        {
            DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);

            try
            {
                writer.AddDocument(segment, doc);
            }
            catch (System.IO.IOException e)
            {
                System.Console.Error.WriteLine(e.StackTrace);
            }
        }
コード例 #3
0
ファイル: DocTest.cs プロジェクト: runefs/Marvin
		public static void  IndexDoc(System.String segment, System.String fileName)
		{
			Directory directory = FSDirectory.GetDirectory("test", false);
			Analyzer analyzer = new SimpleAnalyzer();
			DocumentWriter writer = new DocumentWriter(directory, analyzer, Similarity.GetDefault(), 1000);
			
			System.IO.FileInfo file = new System.IO.FileInfo(fileName);
			Document doc = Lucene.Net.Demo.FileDocument.Document(file);
			
			writer.AddDocument(segment, doc);
			
			directory.Close();
		}
コード例 #4
0
ファイル: TestDoc.cs プロジェクト: yonder/mono
        private void  IndexDoc(System.String segment, System.String fileName)
        {
            Directory      directory = FSDirectory.GetDirectory(indexDir, false);
            Analyzer       analyzer  = new SimpleAnalyzer();
            DocumentWriter writer    = new DocumentWriter(directory, analyzer, Similarity.GetDefault(), 1000);

            System.IO.FileInfo file = new System.IO.FileInfo(workDir.FullName + "\\" + fileName);
            Document           doc  = FileDocument.Document(file);

            writer.AddDocument(segment, doc);

            directory.Close();
        }
コード例 #5
0
ファイル: DocTest.cs プロジェクト: raj581/Marvin
        public static void  IndexDoc(System.String segment, System.String fileName)
        {
            Directory      directory = FSDirectory.GetDirectory("test", false);
            Analyzer       analyzer  = new SimpleAnalyzer();
            DocumentWriter writer    = new DocumentWriter(directory, analyzer, Similarity.GetDefault(), 1000);

            System.IO.FileInfo file = new System.IO.FileInfo(fileName);
            Document           doc  = Lucene.Net.Demo.FileDocument.Document(file);

            writer.AddDocument(segment, doc);

            directory.Close();
        }
コード例 #6
0
ファイル: TestFieldsReader.cs プロジェクト: runefs/Marvin
		protected virtual void  SetUp()
		{
			fieldInfos = new FieldInfos();
			DocHelper.SetupDoc(testDoc);
			fieldInfos.Add(testDoc);
			DocumentWriter writer = new DocumentWriter(dir, new WhitespaceAnalyzer(), Similarity.GetDefault(), 50);
			Assert.IsTrue(writer != null);
			try
			{
				writer.AddDocument("test", testDoc);
			}
			catch (System.IO.IOException e)
			{
				
			}
		}
コード例 #7
0
ファイル: TestFieldsReader.cs プロジェクト: raj581/Marvin
        protected virtual void  SetUp()
        {
            fieldInfos = new FieldInfos();
            DocHelper.SetupDoc(testDoc);
            fieldInfos.Add(testDoc);
            DocumentWriter writer = new DocumentWriter(dir, new WhitespaceAnalyzer(), Similarity.GetDefault(), 50);

            Assert.IsTrue(writer != null);
            try
            {
                writer.AddDocument("test", testDoc);
            }
            catch (System.IO.IOException e)
            {
            }
        }
コード例 #8
0
ファイル: TestDocumentWriter.cs プロジェクト: raj581/Marvin
        public virtual void  TestAddDocument()
        {
            Analyzer       analyzer   = new WhitespaceAnalyzer();
            Similarity     similarity = Similarity.GetDefault();
            DocumentWriter writer     = new DocumentWriter(dir, analyzer, similarity, 50);

            Assert.IsTrue(writer != null);
            try
            {
                writer.AddDocument("test", testDoc);
                //After adding the document, we should be able to read it back in
                SegmentReader reader = new SegmentReader(new SegmentInfo("test", 1, dir));
                Assert.IsTrue(reader != null);
                Document doc = reader.Document(0);
                Assert.IsTrue(doc != null);

                //System.out.println("Document: " + doc);
                Field[] fields = doc.GetFields("textField2");
                Assert.IsTrue(fields != null && fields.Length == 1);
                Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.FIELD_2_TEXT));
                Assert.IsTrue(fields[0].IsTermVectorStored() == true);

                fields = doc.GetFields("textField1");
                Assert.IsTrue(fields != null && fields.Length == 1);
                Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.FIELD_1_TEXT));
                Assert.IsTrue(fields[0].IsTermVectorStored() == false);

                fields = doc.GetFields("keyField");
                Assert.IsTrue(fields != null && fields.Length == 1);
                Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.KEYWORD_TEXT));
            }
            catch (System.IO.IOException e)
            {
                System.Console.Error.WriteLine(e.StackTrace);
                Assert.IsTrue(false);
            }
        }
コード例 #9
0
ファイル: TestDocumentWriter.cs プロジェクト: emtees/old-code
		public virtual void  TestAddDocument()
		{
			Analyzer analyzer = new WhitespaceAnalyzer();
			Similarity similarity = Similarity.GetDefault();
			DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);
			Assert.IsTrue(writer != null);
			try
			{
				writer.AddDocument("test", testDoc);
				//After adding the document, we should be able to read it back in
				SegmentReader reader = new SegmentReader(new SegmentInfo("test", 1, dir));
				Assert.IsTrue(reader != null);
				Document doc = reader.Document(0);
				Assert.IsTrue(doc != null);
				
				//System.out.println("Document: " + doc);
				Field[] fields = doc.GetFields("textField2");
				Assert.IsTrue(fields != null && fields.Length == 1);
				Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.FIELD_2_TEXT));
				Assert.IsTrue(fields[0].IsTermVectorStored() == true);
				
				fields = doc.GetFields("textField1");
				Assert.IsTrue(fields != null && fields.Length == 1);
				Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.FIELD_1_TEXT));
				Assert.IsTrue(fields[0].IsTermVectorStored() == false);
				
				fields = doc.GetFields("keyField");
				Assert.IsTrue(fields != null && fields.Length == 1);
				Assert.IsTrue(fields[0].StringValue().Equals(DocHelper.KEYWORD_TEXT));
			}
			catch (System.IO.IOException e)
			{
                System.Console.Error.WriteLine(e.StackTrace);
				Assert.IsTrue(false);
			}
		}
コード例 #10
0
ファイル: DocHelper.cs プロジェクト: emtees/old-code
		/// <summary> Writes the document to the directory segment using the analyzer and the similarity score</summary>
		/// <param name="">dir
		/// </param>
		/// <param name="">analyzer
		/// </param>
		/// <param name="">similarity
		/// </param>
		/// <param name="">segment
		/// </param>
		/// <param name="">doc
		/// </param>
		public static void  WriteDoc(Directory dir, Analyzer analyzer, Similarity similarity, System.String segment, Document doc)
		{
			DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);
			try
			{
				writer.AddDocument(segment, doc);
			}
			catch (System.IO.IOException e)
			{
				System.Console.Error.WriteLine(e.StackTrace);
			}
		}
コード例 #11
0
ファイル: IndexWriter.cs プロジェクト: ArsenShnurkov/beagle-1
		/// <summary> Adds a document to this index, using the provided analyzer instead of the
		/// value of {@link #GetAnalyzer()}.  If the document contains more than
		/// {@link #SetMaxFieldLength(int)} terms for a given field, the remainder are
		/// discarded.
		/// </summary>
		public virtual void  AddDocument(Document doc, Analyzer analyzer)
		{
			DocumentWriter dw = new DocumentWriter(ramDirectory, analyzer, this);
			dw.SetInfoStream(infoStream);
			System.String segmentName = NewSegmentName();
			dw.AddDocument(segmentName, doc);
			lock (this)
			{
				segmentInfos.Add(new SegmentInfo(segmentName, 1, ramDirectory));
				singleDocSegmentsCount++;
				MaybeMergeSegments();
			}
		}
コード例 #12
0
ファイル: TestDoc.cs プロジェクト: runefs/Marvin
		private void  IndexDoc(System.String segment, System.String fileName)
		{
			Directory directory = FSDirectory.GetDirectory(indexDir, false);
			Analyzer analyzer = new SimpleAnalyzer();
			DocumentWriter writer = new DocumentWriter(directory, analyzer, Similarity.GetDefault(), 1000);
			
			System.IO.FileInfo file = new System.IO.FileInfo(workDir.FullName + "\\" + fileName);
			Document doc = FileDocument.Document(file);
			
			writer.AddDocument(segment, doc);
			
			directory.Close();
		}
コード例 #13
0
ファイル: IndexWriter.cs プロジェクト: zweib730/beagrep
		internal virtual SegmentInfo BuildSingleDocSegment(Document doc, Analyzer analyzer)
		{
			DocumentWriter dw = new DocumentWriter(ramDirectory, analyzer, this);
			dw.SetInfoStream(infoStream);
			System.String segmentName = NewRamSegmentName();
			dw.AddDocument(segmentName, doc);
			return new SegmentInfo(segmentName, 1, ramDirectory, false, false);
		}