lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Terry Steichen" <te...@net-frame.com>
Subject Re: SearchBean Persistence
Date Fri, 05 Jul 2002 14:53:48 GMT
Peter,

OK - but sorry it's not more organized.  Hope you can make sense out of it.

Terry

Changes to CompareDocumentsByField:
 Added a new constructor that includes a sort order flag (int)
 Added a protected field to hold this sort order flag
 modified the return from the compare() method to use sort order flag
(rather than -1)
-----------------------------------------
Changes to HitsIterator:
 Added new constructor that includes a sort order flag (a=ascending,
d=decending, r=relevance)
 Fixed bug - orig line: if((sortFlag != "" ) && (sortFlag != "relevance"))
     new line: if((sortFlag != null) && (!sortFlag.equals("relevance"))
 Add sort order parameter to sortByField() method
 Added a few lines of code inside sortByField() to translate the string sort
order flag to a corresponding int
 Inside sortByField(), call CompareDocumentsByField() with a sort direction
int
---------------------------------------
Changes to SearchBean:
 removed queryString field (unnecessary)
 removed the constructors that had a query string parameter (left only one
constructor - SearchBean(string, string))
 added query string as a parameter to the search() method and modified each
overloaded version for this.
 modified the call to the HitsIterator to include the sort order flag
(string)
 eliminated the toString() method ('cause it had query string in it and I
was too lazy to remove it)
 eliminated the set/getQueryString() method ('cause I now pass it to search)
-------------------------------------
Changes to Hits:
 added int(n) method returning hitDoc(n).id
----------------------------------------
My calling module has this code fragment to set things up:
  SearchBean sb = null;

  if(SortedField.getSortedField(sortfield) == null) {
   SortedField.addField(sortfield, indexdir);
  }
  FSDirectory dir = FSDirectory.getDirectory(indexdir, false);
  sb = new SearchBean(dir, sortfield);

---------------------------
My calling module has this code fragment to do the actual search:

  HitsIterator hi = sb.search(uquery, sortfield, direction);
                hi.setPageSize(num_hits);
  my_hits = hi.getTotalHits();
  int next_page = start_hit / page_size;
  if(start_hit % page_size != 0) {
   next_page++;
  }
  hi.setCurrentPage(next_page);

  while(hi.hasNext()) {
   docs.add(hi.next());
  }

-------------------------------

----- Original Message -----
From: "Peter Carlson" <carlson@bookandhammer.com>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Friday, July 05, 2002 10:19 AM
Subject: Re: SearchBean Persistence


> Hi Terry,
>
> Could you send along you changes so I can integrate them back in.
>
> Thanks
>
> --Peter
>
> On 7/5/02 6:14 AM, "Terry Steichen" <terry@net-frame.com> wrote:
>
> > Peter,
> >
> > The main problem was that I was unfamiliar with the way you used static
> > methods and members.  Once I got my head around that, it wasn't hard to
get
> > things working.  I fixed a couple of minor bugs, got rid of some surplus
> > methods, and added the ability to change the sorting order.  Seems to
work
> > fine now.  Thanks for the help (and the code, of course).
> >
> > Regards,
> >
> > Terry
> >
> >
> > ----- Original Message -----
> > From: "Peter Carlson" <carlson@bookandhammer.com>
> > To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> > Sent: Wednesday, July 03, 2002 11:29 AM
> > Subject: Re: SearchBean Persistence
> >
> >
> >> Hi Terry,
> >>
> >> The way I was hoping it would work is to call static method
> >>
> >> SortedField.addField([field name],[indexPath]);
> >>
> >> In a init servlet at startup (there is a sample servlet in the servelet
> >> directory of the SearchBean contribution).
> >>
> >> Then we you want to sort by that field call the static method
> >>
> >> SortedField.getSortedField([fieldName])
> >>
> >> Which will return the precreated sorted field if it exists.
> >>
> >> Again, I'm sorry I didn't yet have time to fully test this, but this is
> > the
> >> way it SHOULD work. If it doesn't work that way please let me know and
> > I'll
> >> look at it.
> >>
> >> --Peter
> >>
> >>
> >>
> >>
> >> On 7/3/02 7:22 AM, "Terry Steichen" <terry@net-frame.com> wrote:
> >>
> >>> I'm using Peter's SearchBean code to sort search results.  It works
> > fine, but
> >>> it creates the sorting field array from scratch with every invocation
> > (which
> >>> takes on the order of a second or so to complete - each search itself
> > takes
> >>> about one tenth of that or less).  While I can conduct several
searches
> > in the
> >>> same module, I can't figure out how to persist the sorting field array
> > between
> >>> invocations of the search module.
> >>>
> >>> Any advice on how to do this would be much appreciated.
> >>>
> >>> Regards,
> >>>
> >>> Terry
> >>>
> >>>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> > <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> >> For additional commands, e-mail:
> > <mailto:lucene-user-help@jakarta.apache.org>
> >>
> >>
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
>
>


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


Mime
View raw message