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: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
|