On Friday, December 5, 2003, at 01:25 PM, Pleasant, Tracy wrote:
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.

*arg* - we're having a serious communication issue here. My advice to you is to actually write some simple tests (test-driven learning using JUnit is a wonderful way to experiement with Lucene, especially thanks to the RAMDirectory). Please refer to my articles at java.net as well as the other great Lucene articles out there.


Let me try again.... a Field.Keyword *IS* indexed! Even Lucene's javadocs say this for this method:

/** Constructs a String-valued Field that is not tokenized, but is >>>indexed<<<
and stored. Useful for non-text fields, e.g. date or url. */


[I added the emphasis there]


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.

Umm.... you'd use *exactly* the same way as if you had used QueryParser. QueryParser would create a TermQuery for you, in fact, except it would analyze your text first, which is what you want to avoid, right?


Hits.doc(n) gives you back a Document. And then Document.get("fieldName") gives you back the fields (as long as you >>> stored <<< them in the index too).

Again, please attempt some of these things in code. It is a trivial matter to index and search using RAMDirectory and experiment with TermQuery, QueryParser, Analyzers, etc.

Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to