On Fri, Dec 05, 2003 at 01:25:23PM -0500, Pleasant, Tracy wrote: > What I meant is. > > Say ID is Ar3453 .. well the user may want to search for Ar3453, so in > order for it to be searchable then it would have to be indexed and not a > keyword.
No. You should store it as a keyword. >From the javadocs: Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. > > So after using > TermQuery query = new TermQuery(new Term("id", term)); > > How would I return the other fields in the document? > > For instance to display a record it would get the record with the id # > and then display the title, contents, etc. > > > > > -----Original Message----- > From: Erik Hatcher [mailto:[EMAIL PROTECTED] > Sent: Friday, December 05, 2003 11:32 AM > To: Lucene Users List > Subject: Re: Returning one result > > > On Friday, December 5, 2003, at 10:41 AM, Pleasant, Tracy wrote: > > Maybe I should have been more clear. > > > > static Field Keyword(String name, String value) > > Constructs a String-valued Field that is not tokenized, but > > is > > indexed and stored. > > > > I need to have it tokenized because people will search for that also > > and > > it needs to be searchable. > > Search for *what* also? Tokenized means that it is broken into pieces > which will be separate terms. For example: "see spot" is tokenized > into "see" and "spot", and searching for either of those terms will > match. > > Just try it and see, please! :) > > > Should I have two fields - one as a keyword and one as text? > > Depends on what you're doing... but an "id" field to me indicates > Field.Keyword to me, only. > > > How would I do that when I want to return search results.. > > > > Searcher searcher = new IndexSearcher("index"); > > String term = request.getParameter("id"); > > > Query query = QueryParser.parse(term, "id", new > > StandardAnalyzer()); > > > > Hits hits = searcher.search(query); > > > > Would it have to be something like: > > TermQuery query = ??? > > Yes. TermQuery query = new TermQuery(new Term("id", term)); > > Use searcher.search exactly as you did before. Just don't use > QueryParser to construct a query. > > Erik > > > --------------------------------------------------------------------- > 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] > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]