I will try to resume the code:

INDEX TIME
- IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), true);
- writer.setUseCompoundFile(false);
- while has files into the given dir...
- Document doc = new Document();
- doc.add(new Field("content", new FileReader(file)));
- doc.add(new Field("filename", file.getPath(), Field.Store.YES, 
Field.Index.UN_TOKENIZED));
- writer.addDocument(doc);
- end while.
- writer.optimize();
- writer.close();
SEARCH TIME
- Directory directory = FSDirectory.getDirectory(indexDir, false);
- IndexSearcher reader = new IndexSearcher(directory);
- Hits hits = reader.search(new TermQuery(new Term 
("content",keyWordToSearch)));
- Iterator<Hit> i = hits.iterator();
- while (i.hasNext()){
- Hit hit = i.next();
- Document d =(Document) hit.getDocument();
- d.get("filename")

And so, I take the name of the file where the word was found into to do what 
need to do...
I can do when I use only one key word, but more than that, or, if I use some 
word than I know than is found with the operator "+", I can´t find that! :(
 
So, for the Erick questions:
1- In particular, what analyzers you use at index and search time.
    Answer: Standard, only at index time! That´s wrong?!
2- What the string was originally and how you indexed it.
    Answer: I use html, htm and txt files! How I index, is above!
3- What query.toString() shows you.
    Answer: I used no query! Only the reader.search()...

If I write some thing wrong, I´m sorry... :P

Thanks in advance! ;)


----- Mensagem original ----
De: Erick Erickson <[EMAIL PROTECTED]>
Para: java-user@lucene.apache.org
Enviadas: Quinta-feira, 24 de Maio de 2007 13:36:12
Assunto: Re: How to search more than one word?

Not until you give us more information <G>.

In particular, what analyzers you use at index and search time.
What the string was originally and how you indexed it.
What query.toString() shows you.

Best
Erick

On 5/24/07, Rodrigo F Valverde <[EMAIL PROTECTED]> wrote:
>
> Hi all!
>
> I implemented a searcher with Lucene and i´m trying to search two words,
> the both into the same text file, but...i can´t!
>
> When I search the first word and the second separated, everithing happens
> ok, but when together, with or wtithout "AND" or "+"...nothing is found! :(
>
> Can somebody help me?
>
>
>
> __________________________________________________
> Fale com seus amigos  de graça com o novo Yahoo! Messenger
> http://br.messenger.yahoo.com/






__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 

Reply via email to