I wanted to say thank you Danilo.

With your tip and a hunk of code from the Lucene project, I was able to 
significantly enhance searching capabilities on my site.  I need to get a bit 
more understanding of how efficient memory wise a RowReader is.   I am dealing 
with large data sets where people are all searching at the same times, so 
memory requirements could get high.  This is why i was just trying to get a 
distinct selection of service keys.

I am still thinking about the use of anonymous keys.  Right now whenever a 
person updates their record, the search criteria has to be deleted and re-put 
back into the database.   At some point (not anytime vaguely soon) I am going 
to run out of room for the primary key and I would then have to reindex the 
search table.   This seems useless since I don't even want the primary key.  I 
just need to be able to do the 1:N matching.   I am concerned about what was 
said about anonymous keys not working in clustered environment.  I need to 
really understand this better.

Thanks again!!!  It works!!!

JohnE







----- Original Message -----
From: Danilo Tommasina <[EMAIL PROTECTED]>
Date: Tuesday, November 23, 2004 4:44 am
Subject: Re: Unique query without using primary key?

> A ReportQueryByCriteria should do the job:
> 
> something like this:
> 
> Criteria crit = new Criteria();
> crit.addLike( "state", "somestate" );
> crit.addLike( "<ref To SearchWords>.searchword", "somesearchword" );
> 
> ReportQueryByCriteria query = new ReportQueryByCriteria( 
> SearchKeys.class, new String [] { "sid" }, crit, true );
> 
> PersistenceBroker pb = null;
> try {
>   pb = PersistenceBrokerFactory.defaultPersistenceBroker();
> 
>   ArrayList results = new ArrayList();
>   for ( Iterator resultsIt = pb.getReportQueryIteratorByQuery( 
> query ); resultsIt.hasNext(); ) {
>       results.add( ((Object []) resultsIt.next())[ 0 ] );
>   }
> 
>   // The results ArrayList now contains all the ids you need
>   // Note: always extact the values from the Iterator before 
> closing the broker.
> 
> } catch ( Exception e ) {
>   // Do exception handling
> } finally {
>   if ( pb != null ) {
>      pb.close();
>   }
> }
> 
> Replace <ref To SearchWords> with the reference path defined in 
> your repository.xml
> I didn't tested the code, so there are probably syntax errors...
> 
> 
> > I am not getting this.  I need a nudge in the right direction.
> > 
> > I want to do this query:
> >          select distinct sk.sid from searchkeys sk, searchwords sw
> >                where sw.searchword="somesearchword"
> >                             sw.sid = sk.sid
> >                             sk.state="somestate";
> > 
> > table searchkeys:
> >       sid                         <-- unique PK
> >       state
> > 
> > table searchwords:
> >       swid                         <-- unique PK I wish OJB 
> didn't require
> >       sid                           <-- sid in searchkey table
> >       searchword
> > 
> > searchkeys and searchwords having a 1:n relationship.
> > 
> > 
> > Right now I both tables mapped according to their 
> characteristics which I have done many times before.  In the past 
> I have always wanted the primary keys and full records.
> > 
> > Here I don't want the full records or mapping, but just a 
> collection of the unique sid.  I would prefer not to get the full 
> records and I only require this for read and not write.   Imagine 
> I am doing a keyword search and I just want to know which services 
> match the search criteria.
> > 
> > Can anybody nudge me in the right direction?   Would be great to 
> get past this problem.  I am trying to inprove the searching on my 
> live OJB used site by including parts of the Lucene project, but 
> need to be able to do this for it to work.
> > 
> > Thanks lots.
> > 
> > 
> > 
> > 
> > 
> > -----------------------------------------------------------------
> ----
> > 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]
> 
> 


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

Reply via email to