You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "Caughey, Michael" <mc...@trigon.com> on 2002/11/22 15:55:31 UTC
Problem with Range
I am new to Lucene. Last night I started writing a small prototype indexer
and search to become familiar with Lucene before I try to integrate it into
my application. I believe I'm using Lucene correctly, however I can't
figure out why I'm getting the error I am. I have tried searching through
the FAQ's and the mail archive. I hate asking what is probably a stupid
question.
I'm getting the following error with the query shown:
Query : ( DATE:[20021110 - 20021118] )
java.lang.IllegalArgumentException: At least one term must be non-null
Here is the code sample I'm using and below that is the results I'm getting.
I left the two cases which worked in the output. It's the third case that
I'm concerned about.
package lucenetest;
import org.apache.lucene.document.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.lucene.queryParser.*;
import java.util.*;
public class LuceneTest {
private Map writerMap = new HashMap();
private Map searcherMap = new HashMap();
public LuceneTest() {}
private IndexWriter getWriter(String name)throws Exception{
if(!writerMap.containsKey(name)){
writerMap.put(name, new IndexWriter(name, new SimpleAnalyzer(),
true));
}
return (IndexWriter)writerMap.get(name);
}
private Searcher getSearcher(String name)throws Exception{
if(!searcherMap.containsKey(name)){
searcherMap.put(name, new IndexSearcher(name));
}
return (Searcher)searcherMap.get(name);
}
public void addInfo(String indexName, String id, String title, String
description, String date)throws Exception{
IndexWriter writer = getWriter(indexName);
Document doc = new Document();
doc.add(Field.UnIndexed("ID", id));
doc.add(Field.Text("TITLE", title));
doc.add(Field.Text("DESCRIPTION", description));
doc.add(Field.Text("DATE", date));
writer.addDocument(doc);
writer.optimize();
}
public Hits find(String indexName, String title, String description,
String start, String end)throws Exception{
Searcher searcher = getSearcher(indexName);
Analyzer analyzer = new SimpleAnalyzer();
String[] fields = null;
ArrayList fieldList = new ArrayList();
StringBuffer buff = new StringBuffer();
if(title!=null){
buff.append("(TITLE:");
buff.append(title);
buff.append(")");
fieldList.add("TITLE");
}
if(description!=null){
buff.append("(DESCRIPTION:");
buff.append(description);
buff.append(")");
fieldList.add("DESCRIPTION");
}
if(start!=null || end!=null){
buff.append(" ( DATE:[");
buff.append(start);
buff.append(" - ");
buff.append(end);
buff.append("] ) ");
fieldList.add("DATE");
}
Object[] objs = fieldList.toArray();
fields = new String[objs.length];
for (int i = 0; i < objs.length; i++) {
fields[i] = (String)objs[i];
}
System.out.println("Query : " + buff.toString());
Query query = MultiFieldQueryParser.parse(buff.toString(), fields,
analyzer);
return searcher.search(query);
}
public void showHits(Hits hits)throws Exception{
for (int i = 0; i < hits.length(); i++) {
System.out.println("Score = " + hits.score(i) + " : Document = " +
hits.doc(i));
}
System.out.println("==");
System.out.println("====================================");
System.out.println("==");
}
public static void main(String[] args) {
LuceneTest test = new LuceneTest();
try{
test.addInfo("myindex", "1", "This is a book about nothing", "It
really does not contains a damn thing worth mentioning. Read it yourself",
"20021105");
test.addInfo("myindex", "2", "This is a book about Something", "It
really does contains a something worth mentioning. Read it yourself",
"20021126");
test.addInfo("myindex", "3", "This is a book about Everything", "It
really does contains a everything worth mentioning. Read it yourself",
"20021113");
test.addInfo("myindex", "4", "Slim", "He's everything you'd ever want
in a developer", "20021115");
test.addInfo("myindex", "5", "Slim Jim Shady", "I'm not so sure this
is the same guy but he is a developer", "20021103");
test.addInfo("myindex", "6", "Slim Shady", "I know this is not the guy
but he too is a developer who know's everything", "20021125");
test.showHits(test.find("myindex", "This", null, null, null));
test.showHits(test.find("myindex", "This", "everything", null, null));
test.showHits(test.find("myindex", null, null, "20021110",
"20021118"));
}catch(Exception e){
e.printStackTrace(System.out);
}
System.out.println("Done");
}
}
=======RESULTS==========
Query : (TITLE:This)
Score = 0.5787209 : Document = Document<Unindexed<ID:1> Text<TITLE:This is a
book about nothing> Text<DESCRIPTION:It really does not contains a damn
thing worth mentioning. Read it yourself> Text<DATE:20021105>>
Score = 0.5787209 : Document = Document<Text<DATE:20021126>
Text<DESCRIPTION:It really does contains a something worth mentioning. Read
it yourself> Text<TITLE:This is a book about Something> Unindexed<ID:2>>
Score = 0.5787209 : Document = Document<Unindexed<ID:3> Text<TITLE:This is a
book about Everything> Text<DESCRIPTION:It really does contains a everything
worth mentioning. Read it yourself> Text<DATE:20021113>>
==
====================================
==
Query : (TITLE:This)(DESCRIPTION:everything)
Score = 0.4458295 : Document = Document<Unindexed<ID:3> Text<TITLE:This is a
book about Everything> Text<DESCRIPTION:It really does contains a everything
worth mentioning. Read it yourself> Text<DATE:20021113>>
Score = 0.12860465 : Document = Document<Unindexed<ID:1> Text<TITLE:This is
a book about nothing> Text<DESCRIPTION:It really does not contains a damn
thing worth mentioning. Read it yourself> Text<DATE:20021105>>
Score = 0.12860465 : Document = Document<Text<DATE:20021126>
Text<DESCRIPTION:It really does contains a something worth mentioning. Read
it yourself> Text<TITLE:This is a book about Something> Unindexed<ID:2>>
Score = 0.09920931 : Document = Document<Text<DATE:20021115>
Text<DESCRIPTION:He's everything you'd ever want in a developer>
Text<TITLE:Slim> Unindexed<ID:4>>
Score = 0.07593799 : Document = Document<Text<DATE:20021125>
Text<DESCRIPTION:I know this is not the guy but he too is a developer who
know's everything> Text<TITLE:Slim Shady> Unindexed<ID:6>>
==
====================================
==
Query : ( DATE:[20021110 - 20021118] )
java.lang.IllegalArgumentException: At least one term must be non-null
at org.apache.lucene.search.RangeQuery.<init>(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.getRangeQuery(Unknown
Source)
at org.apache.lucene.queryParser.QueryParser.Term(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.Clause(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.Query(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.Clause(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.Query(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.parse(Unknown Source)
at org.apache.lucene.queryParser.QueryParser.parse(Unknown Source)
at org.apache.lucene.queryParser.MultiFieldQueryParser.parse(Unknown
Source)
at lucenetest.LuceneTest.find(LuceneTest.java:80)
at lucenetest.LuceneTest.main(LuceneTest.java:106)
Done
Thanks,
Michael
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with Range
Posted by Michael Caughey <mi...@caughey.com>.
Correct but actually it would be ( DATE:[null - 20020101]) with spaces
around the -.
----- Original Message -----
From: "Clemens Marschner" <cm...@lanlab.de>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Saturday, November 23, 2002 12:18 PM
Subject: Re: Problem with Range
> This probably does not answer your question, but may be a side effect:
>
> > if(start!=null || end!=null){
> > buff.append(" ( DATE:[");
> > buff.append(start);
> > buff.append(" - ");
> > buff.append(end);
> > buff.append("] ) ");
> > fieldList.add("DATE");
>
> This implies that start OR end can be null, producing something like "(
> DATE:[null-20020101])"
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with Range
Posted by Clemens Marschner <cm...@lanlab.de>.
This probably does not answer your question, but may be a side effect:
> if(start!=null || end!=null){
> buff.append(" ( DATE:[");
> buff.append(start);
> buff.append(" - ");
> buff.append(end);
> buff.append("] ) ");
> fieldList.add("DATE");
This implies that start OR end can be null, producing something like "(
DATE:[null-20020101])"
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Doug Cutting <cu...@lucene.com>.
Clemens Marschner wrote:
> So what if documents are deleted in the meantime? Then the recursive merge
> can't determine the X segments with the same size.
If you read my previous message you'll find the answer:
Doug Cutting wrote:
> It's actually a little more complicated than that, since (among other
> reasons) after docuuments are deleted a segment's size will no longer
> be exactly a power of the mergeFactor.
If you want the gory details, look at IndexWriter.java. Or just set
IndexReader.infoStream to System.out, then add and delete documents and
watch what happens.
Doug
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Clemens Marschner <cm...@lanlab.de>.
So what if documents are deleted in the meantime? Then the recursive merge
can't determine the X segments with the same size.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Doug Cutting <cu...@lucene.com>.
No, in my example optimize() was never called. The merge rule operates
recursively. So, after 99 documents had been added the segment stack
contained nine indexes with ten documents and nine with one document.
When the hundredth document was added, the nine one document segments
were popped of the stack and merged into a single segment that was
pushed onto the stack. So then the top of the stack had ten segments
each containing ten documents, i.e., mergeFactor segments of the same
size, and these ten segments were then merged into a single segment of
100 documents. So adding the 100th document triggered two merges.
(One error in my previous example: the 100 document segment actually
contains documents 0-99, not 0-100.)
A corollary of this is, when mergeFactor is 10 and no deletions have
been made, the segments correspond to the digits in the decimal
representation of the number of documents in the index. So, an 85
document index has eight segments with 10 documents and five segments
with one documents. (This is somewhat of a simplification, as Lucene
automatically merges single document segments before ever writing them
to disk as an optimization.)
It is most beneficial to call IndexWriter.optimize() only when you know
you won't be adding documents to an index for a while, but will be
searching it a lot. Calling optimize() periodically while indexing
mostly just slows things down.
Doug
Otis Gospodnetic wrote:
> I see, so every mergeFactor documents they are compined into a single
> new segment in the index, and only when optimize() is called do those
> multiple segments get merged into a single segment.
> In your example below that would mean that optimize() was called after
> document 100 was added, hence a single segment with documents 0-100.
> Is this right?
>
> Thanks,
> Otis
>
> --- Doug Cutting <cu...@lucene.com> wrote:
>
>>Merging happens constantly as documents are added. Each document is
>>initially added in its own segment, and pushed onto the segment
>>stack.
>>Whenever there are mergeFactor segments on the top of the stack that
>>are
>>the same size, these are merged together into a new single segment
>>that
>>replaces them. So, if mergeFactor is 10, and you've added 122
>>documents, the stack will have five segments, as follows:
>> document 121
>> document 120
>> documents 110-119
>> documents 100-109
>> documents 0-100
>>The next merge will happen after document 129 is added, when a new
>>segment will replace the segments for document 120 through document
>>129
>>with a new single segment.
>>
>>It's actually a little more complicated than that, since (among other
>>
>>reasons) after docuuments are deleted a segment's size will no longer
>>be
>>exactly a power of the mergeFactor.
>>
>>Doug
>>
>>Otis Gospodnetic wrote:
>>
>>>This is via mergeFactor?
>>>
>>>--- Doug Cutting <cu...@lucene.com> wrote:
>>>
>>>
>>>>The data is actually removed the next time its segment is merged.
>>>>Optimizing forces it to happen, but it will also eventually happen
>>>
>>as
>>
>>>>more documents are added to the index, without optimization.
>>>>
>>>>Scott Ganyo wrote:
>>>>
>>>>
>>>>>It just marks the record as deleted. The record isn't actually
>>>>
>>>>removed
>>>>
>>>>
>>>>>until the index is optimized.
>>>>>
>>>>>Scott
>>>>>
>>>>>Rob Outar wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Hello all,
>>>>>>
>>>>>> I used the delete(Term) method, then I looked at the index
>>>>>
>>>>files,
>>>>
>>>>
>>>>>>only one
>>>>>>file changed "_1tx.del" I found references to the file still in
>>>>>
>>>>some
>>>>
>>>>
>>>>>>of the
>>>>>>index files, so my question is how does Lucene handle deletes?
>>>>>>
>>>>>>Thanks,
>>>>>>
>>>>>>Rob
>>>>>>
>>>>>>
>>>>>>--
>>>>>>To unsubscribe, e-mail:
>>>>>>For additional commands, e-mail:
>>>>>
>>>>>
>>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>For additional commands, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>
>>>
>>>__________________________________________________
>>>Do you Yahoo!?
>>>Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
>>>http://mailplus.yahoo.com
>>>
>>>--
>>>To unsubscribe, e-mail:
>>
>><ma...@jakarta.apache.org>
>>
>>>For additional commands, e-mail:
>>
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Otis Gospodnetic <ot...@yahoo.com>.
I see, so every mergeFactor documents they are compined into a single
new segment in the index, and only when optimize() is called do those
multiple segments get merged into a single segment.
In your example below that would mean that optimize() was called after
document 100 was added, hence a single segment with documents 0-100.
Is this right?
Thanks,
Otis
--- Doug Cutting <cu...@lucene.com> wrote:
> Merging happens constantly as documents are added. Each document is
> initially added in its own segment, and pushed onto the segment
> stack.
> Whenever there are mergeFactor segments on the top of the stack that
> are
> the same size, these are merged together into a new single segment
> that
> replaces them. So, if mergeFactor is 10, and you've added 122
> documents, the stack will have five segments, as follows:
> document 121
> document 120
> documents 110-119
> documents 100-109
> documents 0-100
> The next merge will happen after document 129 is added, when a new
> segment will replace the segments for document 120 through document
> 129
> with a new single segment.
>
> It's actually a little more complicated than that, since (among other
>
> reasons) after docuuments are deleted a segment's size will no longer
> be
> exactly a power of the mergeFactor.
>
> Doug
>
> Otis Gospodnetic wrote:
> > This is via mergeFactor?
> >
> > --- Doug Cutting <cu...@lucene.com> wrote:
> >
> >>The data is actually removed the next time its segment is merged.
> >>Optimizing forces it to happen, but it will also eventually happen
> as
> >>
> >>more documents are added to the index, without optimization.
> >>
> >>Scott Ganyo wrote:
> >>
> >>>It just marks the record as deleted. The record isn't actually
> >>
> >>removed
> >>
> >>>until the index is optimized.
> >>>
> >>>Scott
> >>>
> >>>Rob Outar wrote:
> >>>
> >>>
> >>>>Hello all,
> >>>>
> >>>> I used the delete(Term) method, then I looked at the index
> >>>
> >>files,
> >>
> >>>>only one
> >>>>file changed "_1tx.del" I found references to the file still in
> >>>
> >>some
> >>
> >>>>of the
> >>>>index files, so my question is how does Lucene handle deletes?
> >>>>
> >>>>Thanks,
> >>>>
> >>>>Rob
> >>>>
> >>>>
> >>>>--
> >>>>To unsubscribe, e-mail:
> >>>>For additional commands, e-mail:
> >>>
> >>>
> >>>
> >>
> >>--
> >>To unsubscribe, e-mail:
> >><ma...@jakarta.apache.org>
> >>For additional commands, e-mail:
> >><ma...@jakarta.apache.org>
> >>
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Doug Cutting <cu...@lucene.com>.
Merging happens constantly as documents are added. Each document is
initially added in its own segment, and pushed onto the segment stack.
Whenever there are mergeFactor segments on the top of the stack that are
the same size, these are merged together into a new single segment that
replaces them. So, if mergeFactor is 10, and you've added 122
documents, the stack will have five segments, as follows:
document 121
document 120
documents 110-119
documents 100-109
documents 0-100
The next merge will happen after document 129 is added, when a new
segment will replace the segments for document 120 through document 129
with a new single segment.
It's actually a little more complicated than that, since (among other
reasons) after docuuments are deleted a segment's size will no longer be
exactly a power of the mergeFactor.
Doug
Otis Gospodnetic wrote:
> This is via mergeFactor?
>
> --- Doug Cutting <cu...@lucene.com> wrote:
>
>>The data is actually removed the next time its segment is merged.
>>Optimizing forces it to happen, but it will also eventually happen as
>>
>>more documents are added to the index, without optimization.
>>
>>Scott Ganyo wrote:
>>
>>>It just marks the record as deleted. The record isn't actually
>>
>>removed
>>
>>>until the index is optimized.
>>>
>>>Scott
>>>
>>>Rob Outar wrote:
>>>
>>>
>>>>Hello all,
>>>>
>>>> I used the delete(Term) method, then I looked at the index
>>>
>>files,
>>
>>>>only one
>>>>file changed "_1tx.del" I found references to the file still in
>>>
>>some
>>
>>>>of the
>>>>index files, so my question is how does Lucene handle deletes?
>>>>
>>>>Thanks,
>>>>
>>>>Rob
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>>For additional commands, e-mail:
>>>
>>>
>>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Otis Gospodnetic <ot...@yahoo.com>.
This is via mergeFactor?
--- Doug Cutting <cu...@lucene.com> wrote:
> The data is actually removed the next time its segment is merged.
> Optimizing forces it to happen, but it will also eventually happen as
>
> more documents are added to the index, without optimization.
>
> Scott Ganyo wrote:
> > It just marks the record as deleted. The record isn't actually
> removed
> > until the index is optimized.
> >
> > Scott
> >
> > Rob Outar wrote:
> >
> >> Hello all,
> >>
> >> I used the delete(Term) method, then I looked at the index
> files,
> >> only one
> >> file changed "_1tx.del" I found references to the file still in
> some
> >> of the
> >> index files, so my question is how does Lucene handle deletes?
> >>
> >> Thanks,
> >>
> >> Rob
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> For additional commands, e-mail:
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Doug Cutting <cu...@lucene.com>.
The data is actually removed the next time its segment is merged.
Optimizing forces it to happen, but it will also eventually happen as
more documents are added to the index, without optimization.
Scott Ganyo wrote:
> It just marks the record as deleted. The record isn't actually removed
> until the index is optimized.
>
> Scott
>
> Rob Outar wrote:
>
>> Hello all,
>>
>> I used the delete(Term) method, then I looked at the index files,
>> only one
>> file changed "_1tx.del" I found references to the file still in some
>> of the
>> index files, so my question is how does Lucene handle deletes?
>>
>> Thanks,
>>
>> Rob
>>
>>
>> --
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Updating documents
Posted by Doug Cutting <cu...@lucene.com>.
A deletion is only visible in other IndexReader instances created after
the IndexReader where you made the deletion is closed. So if you're
searching using a different IndexReader, you need to re-open it after
the deleting IndexReader is closed. The lastModified method helps you
to figure out when this is required. The standard idiom is to cache the
lastModified date returned when a reader is opened, then check it
against the current value before each search. When it is different,
re-open.
Note: If you have many searching threads, it is most efficient for them
to share an IndexReader. But if one thread closes the reader while
others are still searching it, then those searches may crash. So, when
re-opening the index, don't immediately close the old one. Rather just
let the garbage collector close its open files. The only problem with
this approach is that, if your index changes more frequently than the
garbage collector collects old indexes then you can run out of file handles.
Hmm. It would probably make things simpler if an IndexReader cached its
lastModifiedDate when it was opened, so that applications don't have to
do this themseleves to find out whether an IndexReader is out-of-date...
Doug
Rob Outar wrote:
> There is a reloading issue but I do not think lastModified is it:
>
> static long lastModified(Directory directory)
> Returns the time the index in this directory was last modified.
> static long lastModified(File directory)
> Returns the time the index in the named directory was last
> modified.
> static long lastModified(String directory)
> Returns the time the index in the named directory was last
> modified.
>
> Do I need to create a new instance of IndexSearcher each time I search?
>
> Thanks,
>
> Rob
>
>
> -----Original Message-----
> From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> Sent: Friday, November 22, 2002 12:20 PM
> To: Lucene Users List
> Subject: Re: Updating documents
>
>
> Don't you have to make use of lastModified method (I think in
> IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
> pulling this from some old, not very fresh memory....
>
> Otis
>
> --- Rob Outar <ro...@ideorlando.org> wrote:
>
>>I have something odd going on, I have code that updates documents in
>>the
>>index so I have to delete it and then re add it. When I re-add the
>>document
>>I immediately do a search on the newly added field which fails.
>>However, if
>>I rerun the query a second time it works?? I have the Searcher class
>>as an
>>attribute of my search class, does it not see the new changes? Seems
>>like
>>when it is reinitialized with the changed index it is then able to
>>search on
>>the newly added field??
>>
>>Let me know if anyone has encountered this.
>>
>>Thanks,
>>
>>Rob
>>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Updating documents
Posted by Otis Gospodnetic <ot...@yahoo.com>.
Btw. I have posted the code for this before, so you can find it in the
list archives.
Otis
--- Scott Ganyo <sc...@etapestry.com> wrote:
> Not each time you search, but if you've modified the index since you
> opened the searcher, you need to create a new searcher to get the
> changes.
>
> Scott
>
> Rob Outar wrote:
>
> > There is a reloading issue but I do not think lastModified is it:
> >
> > static long lastModified(Directory directory)
> > Returns the time the index in this directory was last
> modified.
> > static long lastModified(File directory)
> > Returns the time the index in the named directory was
> last
> > modified.
> > static long lastModified(String directory)
> > Returns the time the index in the named directory was
> last
> > modified.
> >
> > Do I need to create a new instance of IndexSearcher each time I
> search?
> >
> > Thanks,
> >
> > Rob
> >
> >
> > -----Original Message-----
> > From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> > Sent: Friday, November 22, 2002 12:20 PM
> > To: Lucene Users List
> > Subject: Re: Updating documents
> >
> >
> > Don't you have to make use of lastModified method (I think in
> > IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
> > pulling this from some old, not very fresh memory....
> >
> > Otis
> >
> > --- Rob Outar wrote:
> >
> > >I have something odd going on, I have code that updates documents
> in
> > >the
> > >index so I have to delete it and then re add it. When I re-add
> the
> > >document
> > >I immediately do a search on the newly added field which fails.
> > >However, if
> > >I rerun the query a second time it works?? I have the Searcher
> class
> > >as an
> > >attribute of my search class, does it not see the new changes?
> Seems
> > >like
> > >when it is reinitialized with the changed index it is then able to
> > >search on
> > >the newly added field??
> > >
> > >Let me know if anyone has encountered this.
> > >
> > >Thanks,
> > >
> > >Rob
> > >
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:
> > >
> > >For additional commands, e-mail:
> > >
> > >
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> >
> > For additional commands, e-mail:
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
>
>
> --
> Brain: Pinky, are you pondering what I�m pondering?
> Pinky: I think so, Brain, but calling it a pu-pu platter? Huh, what
> were
> they thinking?
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Updating documents
Posted by Scott Ganyo <sc...@etapestry.com>.
Not each time you search, but if you've modified the index since you
opened the searcher, you need to create a new searcher to get the changes.
Scott
Rob Outar wrote:
> There is a reloading issue but I do not think lastModified is it:
>
> static long lastModified(Directory directory)
> Returns the time the index in this directory was last modified.
> static long lastModified(File directory)
> Returns the time the index in the named directory was last
> modified.
> static long lastModified(String directory)
> Returns the time the index in the named directory was last
> modified.
>
> Do I need to create a new instance of IndexSearcher each time I search?
>
> Thanks,
>
> Rob
>
>
> -----Original Message-----
> From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> Sent: Friday, November 22, 2002 12:20 PM
> To: Lucene Users List
> Subject: Re: Updating documents
>
>
> Don't you have to make use of lastModified method (I think in
> IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
> pulling this from some old, not very fresh memory....
>
> Otis
>
> --- Rob Outar wrote:
>
> >I have something odd going on, I have code that updates documents in
> >the
> >index so I have to delete it and then re add it. When I re-add the
> >document
> >I immediately do a search on the newly added field which fails.
> >However, if
> >I rerun the query a second time it works?? I have the Searcher class
> >as an
> >attribute of my search class, does it not see the new changes? Seems
> >like
> >when it is reinitialized with the changed index it is then able to
> >search on
> >the newly added field??
> >
> >Let me know if anyone has encountered this.
> >
> >Thanks,
> >
> >Rob
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
> >
> >For additional commands, e-mail:
> >
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
>
> For additional commands, e-mail:
>
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
--
Brain: Pinky, are you pondering what I’m pondering?
Pinky: I think so, Brain, but calling it a pu-pu platter? Huh, what were
they thinking?
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Updating documents
Posted by Otis Gospodnetic <ot...@yahoo.com>.
No, only each time the index is modified after the time you created
your last IndexSearcher instance, if I remember correctly.
Otis
--- Rob Outar <ro...@ideorlando.org> wrote:
> There is a reloading issue but I do not think lastModified is it:
>
> static long lastModified(Directory directory)
> Returns the time the index in this directory was last
> modified.
> static long lastModified(File directory)
> Returns the time the index in the named directory was last
> modified.
> static long lastModified(String directory)
> Returns the time the index in the named directory was last
> modified.
>
> Do I need to create a new instance of IndexSearcher each time I
> search?
>
> Thanks,
>
> Rob
>
>
> -----Original Message-----
> From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> Sent: Friday, November 22, 2002 12:20 PM
> To: Lucene Users List
> Subject: Re: Updating documents
>
>
> Don't you have to make use of lastModified method (I think in
> IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
> pulling this from some old, not very fresh memory....
>
> Otis
>
> --- Rob Outar <ro...@ideorlando.org> wrote:
> > I have something odd going on, I have code that updates documents
> in
> > the
> > index so I have to delete it and then re add it. When I re-add the
> > document
> > I immediately do a search on the newly added field which fails.
> > However, if
> > I rerun the query a second time it works?? I have the Searcher
> class
> > as an
> > attribute of my search class, does it not see the new changes?
> Seems
> > like
> > when it is reinitialized with the changed index it is then able to
> > search on
> > the newly added field??
> >
> > Let me know if anyone has encountered this.
> >
> > Thanks,
> >
> > Rob
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Updating documents
Posted by Rob Outar <ro...@ideorlando.org>.
There is a reloading issue but I do not think lastModified is it:
static long lastModified(Directory directory)
Returns the time the index in this directory was last modified.
static long lastModified(File directory)
Returns the time the index in the named directory was last
modified.
static long lastModified(String directory)
Returns the time the index in the named directory was last
modified.
Do I need to create a new instance of IndexSearcher each time I search?
Thanks,
Rob
-----Original Message-----
From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
Sent: Friday, November 22, 2002 12:20 PM
To: Lucene Users List
Subject: Re: Updating documents
Don't you have to make use of lastModified method (I think in
IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
pulling this from some old, not very fresh memory....
Otis
--- Rob Outar <ro...@ideorlando.org> wrote:
> I have something odd going on, I have code that updates documents in
> the
> index so I have to delete it and then re add it. When I re-add the
> document
> I immediately do a search on the newly added field which fails.
> However, if
> I rerun the query a second time it works?? I have the Searcher class
> as an
> attribute of my search class, does it not see the new changes? Seems
> like
> when it is reinitialized with the changed index it is then able to
> search on
> the newly added field??
>
> Let me know if anyone has encountered this.
>
> Thanks,
>
> Rob
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Updating documents
Posted by Otis Gospodnetic <ot...@yahoo.com>.
Don't you have to make use of lastModified method (I think in
IndexSearcher), to 'reload' your instance of IndexSearcher? I'm
pulling this from some old, not very fresh memory....
Otis
--- Rob Outar <ro...@ideorlando.org> wrote:
> I have something odd going on, I have code that updates documents in
> the
> index so I have to delete it and then re add it. When I re-add the
> document
> I immediately do a search on the newly added field which fails.
> However, if
> I rerun the query a second time it works?? I have the Searcher class
> as an
> attribute of my search class, does it not see the new changes? Seems
> like
> when it is reinitialized with the changed index it is then able to
> search on
> the newly added field??
>
> Let me know if anyone has encountered this.
>
> Thanks,
>
> Rob
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Updating documents
Posted by Rob Outar <ro...@ideorlando.org>.
I have something odd going on, I have code that updates documents in the
index so I have to delete it and then re add it. When I re-add the document
I immediately do a search on the newly added field which fails. However, if
I rerun the query a second time it works?? I have the Searcher class as an
attribute of my search class, does it not see the new changes? Seems like
when it is reinitialized with the changed index it is then able to search on
the newly added field??
Let me know if anyone has encountered this.
Thanks,
Rob
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How does delete work?
Posted by Scott Ganyo <sc...@etapestry.com>.
It just marks the record as deleted. The record isn't actually removed
until the index is optimized.
Scott
Rob Outar wrote:
> Hello all,
>
> I used the delete(Term) method, then I looked at the index files,
> only one
> file changed "_1tx.del" I found references to the file still in some
> of the
> index files, so my question is how does Lucene handle deletes?
>
> Thanks,
>
> Rob
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
--
Brain: Pinky, are you pondering what I’m pondering?
Pinky: I think so, Brain, but calling it a pu-pu platter? Huh, what were
they thinking?
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
How does delete work?
Posted by Rob Outar <ro...@ideorlando.org>.
Hello all,
I used the delete(Term) method, then I looked at the index files, only one
file changed "_1tx.del" I found references to the file still in some of the
index files, so my question is how does Lucene handle deletes?
Thanks,
Rob
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>