Results 1 to 4 of 4
- 11-15-2011, 05:25 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Get a token list with search results
I'm lost in Lucene API

I find good results with this code :
Search.TermQuery(my_search_term)
Now I have the good documents containing the search result.
But I would like to get a token list and loop each items in the list to do some statements.
Could you tell me how to do it please ?
- 11-15-2011, 07:12 AM #2
Member
- Join Date
- Nov 2011
- Posts
- 7
- Rep Power
- 0
Re: Get a token list with search results
Hi,
See code below to iterate the search documents and get fields of document.
for(int i=start; i<=stop; i++)
{
Document doc = reader.document(docIds[i].doc);
for (Iterator<Fieldable> iterator = doc.getFields().iterator(); iterator.hasNext();) {
Field field = (Field) iterator.next();
String fieldName;
String fieldValue;
boolean isStored;
boolean isIndexed;
if(field.isStored())
{
fieldName = field.name();
fieldValue = field.stringValue();
isStored = true;
}
if(field.isIndexed())
{
isIndexed = true;
}
}
}
- 11-15-2011, 09:02 AM #3
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Re: Get a token list with search results
Thank you Jayshri.
I didn't think to check if a value is stored or indexed.
Now I only have 2 fields but it will change later so it will be interesting to use it.
if(field.isStored())
{
fieldName = field.name();
fieldValue = field.stringValue();
isStored = true;
}
I wonder how to split "fieldValue" into a list of terms.
Example : "Firefox has located your file and is attempting to retrieve it"
Search term = Firefox
A list of term : Firefox | has | located | your | file | and | is | attempting | to | retrieve | it
A stop word list : has | your | and | is | to | it | ...
A final list of term : Firefox | located | file | attempting | retrieve
Loop final list
Let user choose some associated words
Ex : Firefox + file + retrieve
The main idea is to use Lucene to suggest associated words (for document tagging systems).
- 11-15-2011, 09:16 AM #4
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Re: Get a token list with search results
Thank you Jayshri.
To check if a value is stored or indexed.
Now I only have 2 fields but it will change later so it will be interesting to use it.
if(field.isStored())
{
fieldName = field.name();
fieldValue = field.stringValue();
isStored = true;
}
I wonder how to split "fieldValue" into a list of terms.
Example : "Firefox has located your file and is attempting to retrieve it"
Search term = Firefox
A list of term : Firefox | has | located | your | file | and | is | attempting | to | retrieve | it
A stop word list : has | your | and | is | to | it | ...
A final list of term : Firefox | located | file | attempting | retrieve
Loop final list
Let user choose some associated words
Ex : Firefox + file + retrieve
The main idea is to use Lucene to suggest associated words (for document tagging systems)
Similar Threads
-
search within website & retrieve next results page
By FunkyProg in forum New To JavaReplies: 1Last Post: 03-29-2011, 07:11 AM -
Java - Displaying Search Results in jsp using STRUTS
By selvi in forum Web FrameworksReplies: 0Last Post: 08-12-2010, 07:48 AM -
Design search results .jsp
By maas in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 07-19-2010, 07:18 AM -
Unique Filter on search results
By selva in forum LuceneReplies: 0Last Post: 02-17-2009, 07:32 AM -
Problem with displaying search results from an array
By BHCluster in forum New To JavaReplies: 4Last Post: 04-24-2008, 03:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks