lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pleasant, Tracy" <tracy.pleas...@lmco.com>
Subject RE: Returning one result
Date Fri, 05 Dec 2003 18:45:31 GMT
Also what I am indexing is not a bunch of separate documents - or then
it would be easy to simply have a field called "url" and then the link
would go directly do that document. 

However, there is a text URL with many records
During indexing, a function parses each record and puts each into a
document with appropriate fields. 

When I go to display a particular Document (Lucene Document) I just
query the index for that unique ID rather than go through and parse
through the URL with all the records. 

Wouldn't querying the index for that unique ID be better than going
through that entire page and parsing through it - there is more room for
error that way.  

It's a long story why there isn't a database but it can't be done (don't
ask ... long story). 

-----Original Message-----
From: Pleasant, Tracy 
Sent: Friday, December 05, 2003 1:25 PM
To: Lucene Users List
Subject: RE: Returning one result


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.

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:erik@ehatchersolutions.com]
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: 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


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message