Use the setSort that takes an array of Sort objects...

On Thu, Dec 18, 2008 at 8:11 AM, Ariel <isaacr...@gmail.com> wrote:

> What I am doing is this:
> <code>
>            Sort sort = new Sort();
>            sort.setSort("year", true);
>            hits = searcher.search(pquery,sort);
> </code>
>
> How I must put my code to sort first by date an then by score ???
> Greetings
> Ariel
>
>
> On Thu, Dec 18, 2008 at 4:48 AM, Ian Lea <ian....@gmail.com> wrote:
>
> > Lucene lets you sort by multiple fields, including score.  See the
> > javadocs for Sort and SortField, specifically SortField.SCORE.
> >
> >
> > --
> > Ian.
> >
> > On Wed, Dec 17, 2008 at 8:15 PM, Ariel <isaacr...@gmail.com> wrote:
> > > Hi:
> > > This solution have a problem.
> > > the results are sorted bye the year criteria but I need that after sort
> > by
> > > year criteria it sort by the scoring criteria two.
> > > How can I do this ???
> > >
> > > I hope you can help me.
> > > Greetings
> > > Ariel
> > >
> > > On Wed, Nov 19, 2008 at 5:28 PM, Erick Erickson <
> erickerick...@gmail.com
> > >wrote:
> > >
> > >> Well, MultiSearcher is just a Searcher, so you have available
> > >> all of the search methods on Searcher. One of which is:
> > >>
> > >> search
> > >>
> > >> public TopFieldDocs
> > >>
> > >>
> >
> <file:///C:/lucene-2.1.0/docs/api/org/apache/lucene/search/TopFieldDocs.html>
> > >> *search*(Query
> > >> <file:///C:/lucene-2.1.0/docs/api/org/apache/lucene/search/Query.html>
> > >> query,
> > >>                           Filter
> > >>
> <file:///C:/lucene-2.1.0/docs/api/org/apache/lucene/search/Filter.html>
> > >> filter,
> > >>                           int n,
> > >>                           Sort
> > >> <file:///C:/lucene-2.1.0/docs/api/org/apache/lucene/search/Sort.html>
> > >> sort)
> > >>                    throws IOException
> > >> <http://java.sun.com/j2se/1.4/docs/api/java/io/IOException.html>
> > >>
> > >> Expert: Low-level search implementation with arbitrary sorting. Finds
> > the
> > >> top n hits for query, applying filter if non-null, and sorting the
> hits
> > by
> > >> the criteria in sort.
> > >>
> > >>
> > >> Best
> > >> Erick
> > >>
> > >>
> > >> On Wed, Nov 19, 2008 at 4:22 PM, Ariel <isaacr...@gmail.com> wrote:
> > >>
> > >> > Well, this is what I am doing:
> > >> >
> > >> > queryString="year:[2003 TO 2005]"
> > >> > [CODE]
> > >> >    Query pquery = null;
> > >> >    Hits hits = null;
> > >> >    Analyzer analyzer = null;
> > >> >    analyzer = new SnowballAnalyzer("English");
> > >> >    try {
> > >> >        pquery = MultiFieldQueryParser.parse(new String[]
> {queryString,
> > >> > queryString}, new String[] {"title", "content"}, analyzer);
> //analyzer
> > >> >    } catch (ParseException e1) {
> > >> >        e1.printStackTrace();
> > >> >    }
> > >> >    MultiSearcher searcher = (MultiSearcher) searcherCache.get(name);
> > >> >
> > >> >    try {
> > >> >        hits = searcher.search(pquery);
> > >> >    } catch (IOException e1) {
> > >> >        e1.printStackTrace();
> > >> >    }
> > >> > [/CODE]
> > >> >
> > >> > I don't know the methods that include sorting. I have made the
> sorting
> > by
> > >> > the score criteria so far, I don-t know how to change it to the year
> > >> field
> > >> > criteria.
> > >> > As you can see, I am using a multisearcher because I have several
> > >> indexes.
> > >> >
> > >> > I hope you can help me.
> > >> > Regards
> > >> > Thanks in advance
> > >> > Ariel
> > >> >
> > >> >
> > >> >
> > >> > On Wed, Nov 19, 2008 at 3:58 PM, Ian Lea <ian....@gmail.com> wrote:
> > >> >
> > >> > > Are you using one of the search methods that includes sorting?  If
> > >> > > not, then do.  If you are, then you need to tell us exactly what
> you
> > >> > > are doing and exactly what you reckon is going wrong.
> > >> > >
> > >> > >
> > >> > > --
> > >> > > Ian.
> > >> > >
> > >> > >
> > >> > > On Wed, Nov 19, 2008 at 6:23 PM, Ariel <isaacr...@gmail.com>
> wrote:
> > >> > > > it is supposed lucene make a lexicocraphic sorting but this is
> not
> > >> > > hapening,
> > >> > > > Could you tell me what I'm doing wrong ?
> > >> > > > I hope you can help me.
> > >> > > > Regards
> > >> > > >
> > >> > > > On Wed, Nov 19, 2008 at 11:56 AM, Ariel <isaacr...@gmail.com>
> > wrote:
> > >> > > >
> > >> > > >> Thanks, that was very helpful, but I have a question when I
> make
> > the
> > >> > > >> searches it does not sort the results according to the range,
> for
> > >> > > example:
> > >> > > >> year: [2003 TO 2008] in the first page 2003 documents are
> showed,
> > in
> > >> > the
> > >> > > >> second 2005 documents, in the third page 2004 documents, I
> don't
> > see
> > >> > any
> > >> > > >> sort criteria.
> > >> > > >> How could I fix that problem ???
> > >> > > >> Greetings
> > >> > > >> Ariel
> > >> > > >>
> > >> > > >>
> > >> > > >> On Wed, Nov 19, 2008 at 11:09 AM, Ian Lea <ian....@gmail.com>
> > >> wrote:
> > >> > > >>
> > >> > > >>> Hi - sounds like you need a range query.
> > >> > > >>>
> > >> > > >>>
> > >> > > >>>
> > >> > >
> > >> >
> > >>
> >
> http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Range%20Searches
> > >> > > >>>
> > >> > > >>>
> > >> > > >>> --
> > >> > > >>> Ian.
> > >> > > >>>
> > >> > > >>>
> > >> > > >>> On Wed, Nov 19, 2008 at 4:02 PM, Ariel <isaacr...@gmail.com>
> > >> wrote:
> > >> > > >>> > Hi everybody:
> > >> > > >>> >
> > >> > > >>> > I need to make search with lucene 2.3.2, taking in account
> the
> > >> > dates,
> > >> > > >>> > previously when I build the index I create a date field
> where
> > I
> > >> > > stored
> > >> > > >>> the
> > >> > > >>> > year in which the document was created, at the search moment
> I
> > >> > would
> > >> > > >>> like to
> > >> > > >>> > retrieve documents that have been created before a Year or
> > after
> > >> a
> > >> > > Year,
> > >> > > >>> for
> > >> > > >>> > example documents before 2002 year o after 2003 year.
> > >> > > >>> > It is possible to do that with lucene ???
> > >> > > >>> > Regards
> > >> > > >>> > Ariel
> > >> > > >>> >
> > >> > > >>>
> > >> > > >>>
> > >> ---------------------------------------------------------------------
> > >> > > >>> To unsubscribe, e-mail:
> java-user-unsubscr...@lucene.apache.org
> > >> > > >>> For additional commands, e-mail:
> > java-user-h...@lucene.apache.org
> > >> > > >>>
> > >> > > >>>
> > >> > > >>
> > >> > > >
> > >> > >
> > >> > >
> > ---------------------------------------------------------------------
> > >> > > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> > >> > > For additional commands, e-mail: java-user-h...@lucene.apache.org
> > >> > >
> > >> > >
> > >> >
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> > For additional commands, e-mail: java-user-h...@lucene.apache.org
> >
> >
>

Reply via email to