Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: General

Searching dates at Lucene 1.4.3 webindex

 

 

Lucene general RSS feed   Index | Next | Previous | View Threaded


ers.c at bol

Oct 30, 2006, 6:38 PM

Post #1 of 3 (1438 views)
Permalink
Searching dates at Lucene 1.4.3 webindex

Hi all,

First, thanks a lot Patrick and Grant, you were very very helpful in my last
question! Here comes the final code. The file should have ":" as delimiters
at the files to identify the fields, to work. e.g.:

File.txt
:Title: Web searching in Lucene
:Description: This article presents the results of using a webservice
running Lucene search
:Author: Eder Reboucas
:Content: bla bla bla... etc. e tal


try {
Scanner scanner = new Scanner(f);
scanner.useDelimiter("\\s*:\\s*"); // whitespace and ":"
String campo_nome = new String();
String campo_cont = new String();
while (scanner.hasNext()) {
campo_nome = (campo_nome + scanner.next());
campo_cont = (campo_cont + scanner.next());
doc.add(new Field(campo_nome,campo_cont,true,true,true));
System.out.println("Field Name: " + campo_nome + "\nContent: " +
campo_cont);
campo_nome = "";
campo_cont = "";
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}



I tried to create a String field getting date, or a Date Field to search in
the lucene 1.4.3 lucene web demo, by two ways:

I) Using doc.add(Field.Keyword("modified",
DateField.timeToString(f.lastModified())));

When I try to print it, it returns "0etut1c5k".


II) Using Date Data = new Date ( f.lastModified() );
String arq_data = Data.toLocaleString();
arq_data = arq_data.replaceAll("/","");
arq_data = arq_data.substring(0,8);
doc.add(new Field("Data", arq_data, true, true, true));

When I try to print it, it returns "28102006" - the date.
But when I try to search it by the query "Data: 28102006", it doesn't return
the file.


So, I got the following questions:
I - What does the Field.KeyWord method returns?
II - Would somebody help me exaplining how to turn a date search / indexing
reality in my job?

Great hughes

Eder


sarowe at syr

Oct 31, 2006, 8:43 AM

Post #2 of 3 (1305 views)
Permalink
Re: Searching dates at Lucene 1.4.3 webindex [In reply to]

Eder wrote:
> But when I try to search it by the query "Data: 28102006", it doesn't
> return the file.

Maybe try removing the space: "Data: 28102006" -> "Data:28102006"?


ers.c at bol

Nov 2, 2006, 8:44 AM

Post #3 of 3 (1300 views)
Permalink
Re: Searching dates at Lucene 1.4.3 webindex [In reply to]

Hi Steve

It didn't work! Anyway, when I try to search other fields including spaces,
it works! The problem it's with date maniputalion =[

Anyway, thanks a lot! We c!


----- Original Message -----
From: "Steven Rowe" <sarowe [at] syr>
To: <general [at] lucene>
Sent: Tuesday, October 31, 2006 1:43 PM
Subject: Re: Searching dates at Lucene 1.4.3 webindex


> Eder wrote:
>> But when I try to search it by the query "Data: 28102006", it doesn't
>> return the file.
>
> Maybe try removing the space: "Data: 28102006" -> "Data:28102006"?

Lucene general RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.