RE: IndexWriter and Directory create param

2003-06-10 Thread Leslie Hughes
Hi Otis, Thanks for the reply.  

My DirectoryImpl is configurable in a config file so I dynamically
instantiate whatever's listed there. Because of the private constructor in
FSDir and the lack of getDirectory on the interface, I'm having to do :-

 try{
  //Make an FSDir if it's one of those
  return (Directory)Class.forName(myDefaultDirectoryImpl)
  .getMethod("getDirectory", new Class[] {String.class,
boolean.class})
  .invoke(null, new Object[]{myDefaultIndex, new Boolean(false)});
  }catch(Exception ioe) {  }

Which I think is rather funky :-) but some would say not very clean
Anyway adding a getDirectory to the Directory class would be rather neat
then I could use the above for all dirs - this doesn't work with RAMDir or
DBDir at the moment of course - and wrap the whole lot into a
DirectoryFactory+config.xml file.

On the other point, I've decided to go with creating the new index via the
writer - no real reason, just couldn't see why not :-)  


Bye

Les





> -Original Message-
> From: Otis Gospodnetic [SMTP:[EMAIL PROTECTED]
> Sent: Tuesday, June 10, 2003 3:02 PM
> To:   Lucene Users List
> Subject:  Re: IndexWriter and Directory create param
> 
> Hello Les,
> 
> > Directory dir = FSDirectory.getDirectory("myindex", true);
> > IndexWriter writer = new IndexWriter(dir, myAnalyser, true);
> > 
> > which gives me a nice clean index. But what if the create params are
> > different? If I open a directory with create=false then create a
> > writer on it with create = true will this give problems?
> 
> If I understand you correctly, then the answer is: no, this should not
> cause problems.  You could easily try that, no?
> 
> > Maybe I should do something like
> > 
> > boolean flag = true/false;
> > Directory dir = FSDirectory.getDirectory("myindex", flag);
> > IndexWriter writer = new IndexWriter(dir, myAnalyser, false);
> 
> I've seen people use code like that.
> 
> > Whilst I'm on the subject, there doesn't appear to be a standard way
> > of creating a Directory, FSDir has a getDirectory whilst RAMDir uses
> a
> > constructor - shouldn't there be a standard method on the Directory
> > interface (like there is with close)? Or maybe a configurable
> > DirectoryFactory?
> 
> Perhaps.  Directory is an abstract class.  One could add an abstract
> open(...) method, maybe.  I don't have a need for it...
> 
> Otis
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



IndexWriter and Directory create param

2003-06-09 Thread Leslie Hughes
Hi,

I'm doing something like:-

Directory dir = FSDirectory.getDirectory("myindex", true);
IndexWriter writer = new IndexWriter(dir, myAnalyser, true);

which gives me a nice clean index. But what if the create params are
different? If I open a directory with create=false then create a writer on
it with create = true will this give problems? Maybe I should do something
like

boolean flag = true/false;
Directory dir = FSDirectory.getDirectory("myindex", flag);
IndexWriter writer = new IndexWriter(dir, myAnalyser, false);


Whilst I'm on the subject, there doesn't appear to be a standard way of
creating a Directory, FSDir has a getDirectory whilst RAMDir uses a
constructor - shouldn't there be a standard method on the Directory
interface (like there is with close)? Or maybe a configurable
DirectoryFactory?


Ideas?

Bye

Les




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Lowercasing wildcards - why?

2003-05-30 Thread Leslie Hughes
Hi,

I was just wondering what the rationale is behind lowercasing wildcard
queries produced by QueryParser? It's just that my data is all upper case
and my analyser doesn't lowercase so it seems a bit odd that I have to call
setLowercaseWildcardTerms(false). Couldn't queryparser leave the terms
unnormalised or better still pass them through the analyser?

I'm sure there's a good reason for it though.


Les



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



PhraseQuery question

2003-05-28 Thread Leslie Hughes

Hi,

I'm playing with PhraseQuery on an index of address data. If I do

 PhraseQuery pq = new PhraseQuery();
  pq.add(new Term("SUBURB_NAME","PERTH GPO"));
  log.debug("Searching for: " + pq.toString());
  Hits hits = searcher.search(pq);

I get no hits and debug info of 
Searching for: SUBURB_NAME:"PERTH GPO"

If I do
 PhraseQuery pq = new PhraseQuery();
 pq.add(new Term("SUBURB_NAME","PERTH"));
 pq.add(new Term("SUBURB_NAME","GPO"));
 log.debug("Searching for: " + pq.toString());
 Hits hits = searcher.search(pq);

I get the same debug query string
Searching for: SUBURB_NAME:"PERTH GPO"

but this time I get a bunch of hits back.

I'm using a real simple analyzer for the indexer:-

public final TokenStream tokenStream(String fieldName, Reader reader) {
return new WhitespaceTokenizer(reader);
}

What's going on?


Bye
Les



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]