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 Karthik N S <ka...@controlnet.co.in> on 2004/12/02 08:13:50 UTC
UNIQUE FIELD NAMES + SEARCH
Hi Guys'
Apologies........
I My Index, I have a Filed Type KeyWord ' FILE_NAME ' , It Captures UNIQUE
FOLDER NAME'S [ Starts with B1,B2,B3..... ] During Indexing Process.
Please Can SomeBody Tell me How to Display ALL the FOLDER NAMES from the
Field 'FILE_NAME' With out any Search Word
[ Can I use 'B* ' for Search Exclusively on the Field Type ]
Thx in Advance
WITH WARM REGARDS
HAVE A NICE DAY
[ N.S.KARTHIK]
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
RE: UNIQUE FIELD NAMES + SEARCH
Posted by Karthik N S <ka...@controlnet.co.in>.
Hi Erik
Apologies...
Thx That src worked perfectly.
Wow that really overcame a huge boulder for me.
.......... :|
with regards
Karthik
-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
Sent: Thursday, December 02, 2004 4:23 PM
To: Lucene Users List
Subject: Re: UNIQUE FIELD NAMES + SEARCH
On Dec 2, 2004, at 2:13 AM, Karthik N S wrote:
> I My Index, I have a Filed Type KeyWord ' FILE_NAME ' , It Captures
> UNIQUE
> FOLDER NAME'S [ Starts with B1,B2,B3..... ] During Indexing Process.
>
> Please Can SomeBody Tell me How to Display ALL the FOLDER NAMES from
> the
> Field 'FILE_NAME' With out any Search Word
I guess if you keep asking, someone will eventually answer :)
Here's an example I use to get all categories from the Lucene index
that drives my blog at http://www.blogscene.org/erik
Set categories = new TreeSet();
IndexReader reader = IndexReader.open(indexDir);
try {
TermEnum terms = reader.terms(new Term("category", ""));
while ("category".equals(terms.term().field())) {
categories.add(terms.term().text());
if (!terms.next()) {
break;
}
}
} finally {
reader.close();
}
IndexReader is enumerating all the terms in the "category" field
(you'll use your filename field name instead).
> [ Can I use 'B* ' for Search Exclusively on the Field Type ]
Sure, but that would require that you walk every document returned from
the search and pull its filename field. This would be vastly slower
than the above code that goes directly to the terms.
My apologies for not replying sooner on this.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: UNIQUE FIELD NAMES + SEARCH
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Dec 2, 2004, at 2:13 AM, Karthik N S wrote:
> I My Index, I have a Filed Type KeyWord ' FILE_NAME ' , It Captures
> UNIQUE
> FOLDER NAME'S [ Starts with B1,B2,B3..... ] During Indexing Process.
>
> Please Can SomeBody Tell me How to Display ALL the FOLDER NAMES from
> the
> Field 'FILE_NAME' With out any Search Word
I guess if you keep asking, someone will eventually answer :)
Here's an example I use to get all categories from the Lucene index
that drives my blog at http://www.blogscene.org/erik
Set categories = new TreeSet();
IndexReader reader = IndexReader.open(indexDir);
try {
TermEnum terms = reader.terms(new Term("category", ""));
while ("category".equals(terms.term().field())) {
categories.add(terms.term().text());
if (!terms.next()) {
break;
}
}
} finally {
reader.close();
}
IndexReader is enumerating all the terms in the "category" field
(you'll use your filename field name instead).
> [ Can I use 'B* ' for Search Exclusively on the Field Type ]
Sure, but that would require that you walk every document returned from
the search and pull its filename field. This would be vastly slower
than the above code that goes directly to the terms.
My apologies for not replying sooner on this.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org