You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2008/03/25 09:35:27 UTC

[jira] Resolved: (LUCENE-1244) Get rid of (another) hard coded path

     [ https://issues.apache.org/jira/browse/LUCENE-1244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-1244.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.4

I just committed this.  Thanks Hasan!

> Get rid of (another) hard coded path
> ------------------------------------
>
>                 Key: LUCENE-1244
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1244
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Analysis
>            Reporter: Hasan Diwan
>            Priority: Minor
>             Fix For: 2.4
>
>         Attachments: lucene.pat
>
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3
: Message-ID: <0D...@CORPUSMX70B.corp.emc.com>
: In-Reply-To: <18...@brutus>

http://people.apache.org/~hossman/#threadhijack

Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/Thread_hijacking

You message was in an existing thread regarding jira issue LUCENE-1244


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3

Posted by Michael McCandless <lu...@mikemccandless.com>.
Ahhh, OK.  In 2.3, when you open IndexWriter with autoCommit=false,  
the only way to make changes visible is to close the writer.  Can you  
just open with autoCommit=true?  Then flush() makes changes visible.   
You can increase the flushing criteria to absurdly large values so  
the writer never flushes on its own, if that's necessary.

In 2.4, even when autoCommit=false, you can make changes visible  
(and, durable to power outage or OS/machine crash) by calling commit 
().  But remember 2.4 is trunk so "use at your own risk"!

Both flush() and commit() are rather costly operations, so calling  
them too frequently will hurt your indexing throughput.

Mike

Liu_Chao@emc.com wrote:
> I used the new released 2.3 and set autoCommit=false.
>
> Sorry my code to create the IndexWriter is like this:
> 	      Directory dir = FSDirectory.getDirectory(INDEX_DIR);
> 	      IndexWriter writer = new IndexWriter(dir, false, new  
> StandardAnalyzer(), true);
> 	      writer.setTermIndexInterval(8);
> 	      writer.setMaxBufferedDocs(3);
> 	      writer.setMergeFactor(3);
>
> I just would like to control the flush of the segments by myself.
>
> But in the released 2.3, there is no interface for users to flush  
> the segments by themselves, right?
>
> If I would like to achieve this, do you mean I have to use the 2.4  
> version instead of 2.3?
>
> Thank you
>
> Yours
>
> Liu Chao
>
> -----Original Message-----
> From: Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: 2008年3月25日 17:21
> To: java-dev@lucene.apache.org
> Subject: Re: IndexWriter.flush dose not flush the segmentInfos in  
> Lucene 2.3
>
>
> Do you mean 2.4 (trunk) not 2.3?  In 2.4, flush has been deprecated.
> Instead, you should use commit() to force the changes to be visible
> to a reader.
>
> On 2.3 I believe this works correctly as long as the write is opened
> with autoCommit=true (which your example below is).
>
> Mike
>
> Liu_Chao@emc.com wrote:
>> I found that for lucene 2.3, IndexWriter.flush does not flush the
>> segmentInfos.
>>
>> For example, I create a new index directory and add 10 documents to
>> it:
>>
>> 	IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
>> true);
>> 	indexDocs(writer, SOURCE_DIR);//in the source directory, there are
>> 10 documents.
>> 	writer.flush();
>>
>> If the IndexWriter is not closed and then an IndexReader is opened
>> to this index:
>>
>> 	IndexReader reader = IndexReader.open(INDEX_DIR);
>> 	int docNum = reader.numDocs();//docNum = 0
>>
>> at this time, docNum = 0, the new opened IndexReader cannot see the
>> new added documents.
>>
>> But if the IndexWriter is closed and then an IndexReader is opened
>> to the Index:
>>
>> 	writer.close();
>> 	IndexReader reader = IndexReader.open(index);
>> 	int docNum = reader.numDocs();//docNum = 10
>>
>> at this time the new opened IndexReader can see the documents added
>> by the IndexWriter.
>>
>> I think the reason is :
>>
>> IndexWriter.flush only flushes the data from memory to disk, the
>> metadata of segments segmentInfos is not flushed to the disk.
>>
>> So that if the IndexWriter is not closed, the new opened
>> IndexReader cannot see the new added documents.
>>
>> That means what the IndexReader can see is not the segment
>> structure when it is opened but when the last time the IndexWriter
>> is opened.
>>
>>
>> I think it is a bug for new version of lucene 2.3 or at least the
>> behavior is different from lucene 2.1
>>
>>
>> Yours
>>
>> Liu Chao
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


RE: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3

Posted by Li...@emc.com.
I used the new released 2.3 and set autoCommit=false.

Sorry my code to create the IndexWriter is like this:
	      Directory dir = FSDirectory.getDirectory(INDEX_DIR);
	      IndexWriter writer = new IndexWriter(dir, false, new StandardAnalyzer(), true);
	      writer.setTermIndexInterval(8);
	      writer.setMaxBufferedDocs(3);
	      writer.setMergeFactor(3);

I just would like to control the flush of the segments by myself.

But in the released 2.3, there is no interface for users to flush the segments by themselves, right?

If I would like to achieve this, do you mean I have to use the 2.4 version instead of 2.3?

Thank you

Yours

Liu Chao

-----Original Message-----
From: Michael McCandless [mailto:lucene@mikemccandless.com] 
Sent: 2008年3月25日 17:21
To: java-dev@lucene.apache.org
Subject: Re: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3


Do you mean 2.4 (trunk) not 2.3?  In 2.4, flush has been deprecated.   
Instead, you should use commit() to force the changes to be visible  
to a reader.

On 2.3 I believe this works correctly as long as the write is opened  
with autoCommit=true (which your example below is).

Mike

Liu_Chao@emc.com wrote:
> I found that for lucene 2.3, IndexWriter.flush does not flush the  
> segmentInfos.
>
> For example, I create a new index directory and add 10 documents to  
> it:
>
> 	IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),  
> true);
> 	indexDocs(writer, SOURCE_DIR);//in the source directory, there are  
> 10 documents.
> 	writer.flush();
>
> If the IndexWriter is not closed and then an IndexReader is opened  
> to this index:
>
> 	IndexReader reader = IndexReader.open(INDEX_DIR);
> 	int docNum = reader.numDocs();//docNum = 0
>
> at this time, docNum = 0, the new opened IndexReader cannot see the  
> new added documents.
>
> But if the IndexWriter is closed and then an IndexReader is opened  
> to the Index:
>
> 	writer.close();
> 	IndexReader reader = IndexReader.open(index);
> 	int docNum = reader.numDocs();//docNum = 10
>
> at this time the new opened IndexReader can see the documents added  
> by the IndexWriter.
>
> I think the reason is :
>
> IndexWriter.flush only flushes the data from memory to disk, the  
> metadata of segments segmentInfos is not flushed to the disk.
>
> So that if the IndexWriter is not closed, the new opened  
> IndexReader cannot see the new added documents.
>
> That means what the IndexReader can see is not the segment  
> structure when it is opened but when the last time the IndexWriter  
> is opened.
>
>
> I think it is a bug for new version of lucene 2.3 or at least the  
> behavior is different from lucene 2.1
>
>
> Yours
>
> Liu Chao


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3

Posted by Michael McCandless <lu...@mikemccandless.com>.
Do you mean 2.4 (trunk) not 2.3?  In 2.4, flush has been deprecated.   
Instead, you should use commit() to force the changes to be visible  
to a reader.

On 2.3 I believe this works correctly as long as the write is opened  
with autoCommit=true (which your example below is).

Mike

Liu_Chao@emc.com wrote:
> I found that for lucene 2.3, IndexWriter.flush does not flush the  
> segmentInfos.
>
> For example, I create a new index directory and add 10 documents to  
> it:
>
> 	IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),  
> true);
> 	indexDocs(writer, SOURCE_DIR);//in the source directory, there are  
> 10 documents.
> 	writer.flush();
>
> If the IndexWriter is not closed and then an IndexReader is opened  
> to this index:
>
> 	IndexReader reader = IndexReader.open(INDEX_DIR);
> 	int docNum = reader.numDocs();//docNum = 0
>
> at this time, docNum = 0, the new opened IndexReader cannot see the  
> new added documents.
>
> But if the IndexWriter is closed and then an IndexReader is opened  
> to the Index:
>
> 	writer.close();
> 	IndexReader reader = IndexReader.open(index);
> 	int docNum = reader.numDocs();//docNum = 10
>
> at this time the new opened IndexReader can see the documents added  
> by the IndexWriter.
>
> I think the reason is :
>
> IndexWriter.flush only flushes the data from memory to disk, the  
> metadata of segments segmentInfos is not flushed to the disk.
>
> So that if the IndexWriter is not closed, the new opened  
> IndexReader cannot see the new added documents.
>
> That means what the IndexReader can see is not the segment  
> structure when it is opened but when the last time the IndexWriter  
> is opened.
>
>
> I think it is a bug for new version of lucene 2.3 or at least the  
> behavior is different from lucene 2.1
>
>
> Yours
>
> Liu Chao


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


IndexWriter.flush dose not flush the segmentInfos in Lucene 2.3

Posted by Li...@emc.com.
I found that for lucene 2.3, IndexWriter.flush does not flush the segmentInfos.

For example, I create a new index directory and add 10 documents to it:

	IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
	indexDocs(writer, SOURCE_DIR);//in the source directory, there are 10 documents.
	writer.flush();

If the IndexWriter is not closed and then an IndexReader is opened to this index:

	IndexReader reader = IndexReader.open(INDEX_DIR);
	int docNum = reader.numDocs();//docNum = 0

at this time, docNum = 0, the new opened IndexReader cannot see the new added documents.

But if the IndexWriter is closed and then an IndexReader is opened to the Index:

	writer.close();
	IndexReader reader = IndexReader.open(index);
	int docNum = reader.numDocs();//docNum = 10

at this time the new opened IndexReader can see the documents added by the IndexWriter.

I think the reason is :

IndexWriter.flush only flushes the data from memory to disk, the metadata of segments segmentInfos is not flushed to the disk. 

So that if the IndexWriter is not closed, the new opened IndexReader cannot see the new added documents. 

That means what the IndexReader can see is not the segment structure when it is opened but when the last time the IndexWriter is opened. 


I think it is a bug for new version of lucene 2.3 or at least the behavior is different from lucene 2.1


Yours

Liu Chao