Return-Path: Delivered-To: apmail-incubator-lucene-net-user-archive@minotaur.apache.org Received: (qmail 12185 invoked from network); 3 Nov 2009 16:29:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Nov 2009 16:29:54 -0000 Received: (qmail 34153 invoked by uid 500); 3 Nov 2009 16:29:53 -0000 Delivered-To: apmail-incubator-lucene-net-user-archive@incubator.apache.org Received: (qmail 33702 invoked by uid 500); 3 Nov 2009 16:29:52 -0000 Mailing-List: contact lucene-net-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-user@incubator.apache.org Delivered-To: mailing list lucene-net-user@incubator.apache.org Received: (qmail 33575 invoked by uid 99); 3 Nov 2009 16:29:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 16:29:52 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andre.maldonado@gmail.com designates 209.85.223.195 as permitted sender) Received: from [209.85.223.195] (HELO mail-iw0-f195.google.com) (209.85.223.195) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 16:29:49 +0000 Received: by iwn33 with SMTP id 33so4156723iwn.21 for ; Tue, 03 Nov 2009 08:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=kTWkFSFGkM/XNVzfaFVTlH/DWYVSDf2Z822OCkG8C9g=; b=HQpDvUtlWvB4fHI6bOW8dAvqz8htXclD5If26kGZV1xfuSrXCj7I17MWNhysPvyT9B l/2pwT6Pvqwf+ebHHj63gRFvmD2h7N8fH9pey53jTwaeVWO41wlHusoTC+gz2KEdmR2J vKj1Y4vgHmA5KepSqhecKJDJ/iVo0HiRNwyuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=NttA1QnP/8gguZ9F5L8F3JYXZar+UQ1Hhlo/dilGeQZFNd7/BWndW8PEWPdwkG7Qid z4HedpLTXM92T64xzhh4ZRMA+Q+DoUe4P1DQn8YjUEJ5EdXGT5S9u79VhB8AOakjhk9d zWIDXTVXd/vuTZ0JzliA2BQOUHRetmuS8LsrU= MIME-Version: 1.0 Received: by 10.231.125.100 with SMTP id x36mr428014ibr.52.1257265767394; Tue, 03 Nov 2009 08:29:27 -0800 (PST) In-Reply-To: References: From: =?ISO-8859-1?Q?Andr=E9_Maldonado?= Date: Tue, 3 Nov 2009 14:29:07 -0200 Message-ID: Subject: Re: Simple question To: lucene-net-user@incubator.apache.org Content-Type: multipart/alternative; boundary=0016e646432c742f8c047779ffa9 --0016e646432c742f8c047779ffa9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This thread is getting big... Franklin, I totally agree this approach can result in a problem, but I don'= t know yet how to do this search with TermEnum. What is the basic documentation to learn (I mean really learn, with all different query types= ) about queries? Thank's "Ent=E3o aproximaram-se os que estavam no barco, e adoraram-no, dizendo: = =C9s verdadeiramente o Filho de Deus." (Mateus 14:33) On Tue, Nov 3, 2009 at 13:33, Franklin Simmons wrote: > Andr=E9, > > You can pass null for the filter parameter. TopDocCollector and > TopFieldDocCollector lets you limit hits. I have to say that while this > approach may seem OK with a very small index it will become a major probl= em > for you as index size grows, because MatchAllDocsQuery results in a sorti= ng > of all documents in the index having the sort field. You should heed the > advice offered by Digy earlier in this discussion to use TermEnum. > > > -----Original Message----- > From: Andr=E9 Maldonado [mailto:andre.maldonado@gmail.com] > Sent: Tuesday, November 03, 2009 8:50 AM > To: lucene-net-user@incubator.apache.org > Subject: Re: Simple question > > When I do: > > Hits hits =3D searcher.Search(new *MatchAllDocsQuery()*, sort); > > The searcher return all documents. Can I return only the first 5 document= s? > Like a TOP 5 in SQL Server? > > Probably using searcher.Search(Query query, Filter filter, int n, Sort > sort) > I can do it, but I don't have a filter.. > > How can I do it? > > Thank's > > > "Ent=E3o aproximaram-se os que estavam no barco, e adoraram-no, dizendo: = =C9s > verdadeiramente o Filho de Deus." (Mateus 14:33) > > > 2009/11/3 Andr=E9 Maldonado > > > Franklin, the error was exactly that. > > > > Some documents had a string where only an int can be. After made some > code > > adjustment, reindexing everything made it work. > > > > > > Thank's > > > > "Ent=E3o aproximaram-se os que estavam no barco, e adoraram-no, dizendo= : =C9s > > verdadeiramente o Filho de Deus." (Mateus 14:33) > > > > > > On Fri, Oct 30, 2009 at 18:19, Franklin Simmons < > > fsimmons@sccmediaserver.com> wrote: > > > >> What type of data is represented by your field? > >> > >> There are any number of reasons why this could happen, such as using > >> SortField.INT on a field with terms having non-digit characters. > >> > >> Without knowing specifics, I can only offer that you try > SortField.STRING. > >> > >> -----Original Message----- > >> From: Andr=E9 Maldonado [mailto:andre.maldonado@gmail.com] > >> Sent: Friday, October 30, 2009 3:47 PM > >> To: lucene-net-user@incubator.apache.org > >> Subject: Re: Simple question > >> > >> Hi again Franklin. > >> > >> Sorry, but didn't work. I'm using Lucene.net 2.3 and doing exactly wha= t > >> you > >> said, I'm getting this error: > >> > >> System.FormatException: Input string was not in correct format. > >> em System.Number.StringToNumber(String str, NumberStyles options, > >> NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) > >> em System.Number.ParseInt32(String s, NumberStyles style, > >> NumberFormatInfo info) > >> em > >> Lucene.Net.Search.FieldCacheImpl.AnonymousClassIntParser.ParseInt(Stri= ng > >> value_Renamed) > >> em > >> > >> > Lucene.Net.Search.FieldCacheImpl.AnonymousClassCache2.CreateValue(IndexRe= ader > >> reader, Object entryKey) > >> em Lucene.Net.Search.FieldCacheImpl.Cache.Get(IndexReader reader, > Object > >> key) > >> em Lucene.Net.Search.FieldCacheImpl.GetInts(IndexReader reader, Stri= ng > >> field, IntParser parser) > >> em Lucene.Net.Search.FieldCacheImpl.GetInts(IndexReader reader, Stri= ng > >> field) > >> em Lucene.Net.Search.FieldSortedHitQueue.ComparatorInt(IndexReader > >> reader, String fieldname) > >> em > >> > >> > Lucene.Net.Search.FieldSortedHitQueue.AnonymousClassCache.CreateValue(Ind= exReader > >> reader, Object entryKey) > >> em Lucene.Net.Search.FieldCacheImpl.Cache.Get(IndexReader reader, > Object > >> key) > >> em > Lucene.Net.Search.FieldSortedHitQueue.GetCachedComparator(IndexReader > >> reader, String field, Int32 type, CultureInfo locale, > SortComparatorSource > >> factory) > >> em Lucene.Net.Search.FieldSortedHitQueue..ctor(IndexReader reader, > >> SortField[] fields, Int32 size) > >> em Lucene.Net.Search.IndexSearcher.Search(Weight weight, Filter > filter, > >> Int32 nDocs, Sort sort) > >> em Lucene.Net.Search.Hits.GetMoreDocs(Int32 min) > >> em Lucene.Net.Search.Hits..ctor(Searcher s, Query q, Filter f, Sort = o) > >> em Lucene.Net.Search.Searcher.Search(Query query, Sort sort) > >> em SearcherLibrary.Searcher.Search(String[] fields, String orderBy, > >> Int32 > >> type, Object analyzer) na > >> > c:\Maldonado\projetos\BuscaBlog\Indexer\SearcherLibrary\Searcher.cs:linha > >> 252 > >> em SearcherLibrary.Searcher.Search(String orderBy, sortType type, > Int32 > >> hitCount) na > >> > c:\Maldonado\projetos\BuscaBlog\Indexer\SearcherLibrary\Searcher.cs:linha > >> 313 > >> em IndexerConsole.Program.Main(String[] args) na > >> c:\Maldonado\projetos\BuscaBlog\Indexer\IndexerConsole\Program.cs:linh= a > 21 > >> > >> Any idea? > >> > >> Thank's > >> > >> "Ent=E3o aproximaram-se os que estavam no barco, e adoraram-no, dizend= o: > =C9s > >> verdadeiramente o Filho de Deus." (Mateus 14:33) > >> > >> > >> On Fri, Oct 30, 2009 at 16:06, Franklin Simmons < > >> fsimmons@sccmediaserver.com > >> > wrote: > >> > >> > I did it again, think I'll hang it up for the day. The correct quer= y > >> class > >> > name is 'MatchAllDocsQuery'. > >> > > >> > -----Original Message----- > >> > From: Franklin Simmons [mailto:fsimmons@sccmediaserver.com] > >> > Sent: Friday, October 30, 2009 2:06 PM > >> > To: lucene-net-user@incubator.apache.org > >> > Subject: RE: Simple question > >> > > >> > Oops, I'm not being very helpful. > >> > > >> > Use the MatchAllDocumentsQuery class: > >> > > >> > Searcher searcher =3D new IndexSearcher(directory); > >> > > >> > Sort =3D new Sort(new SortField("another_field", SortField.AUTO, > false)); > >> > > >> > Hits hits =3D searcher.search(new MatchAllDocumentsQuery(),sort); > >> > > >> > > >> > However, that may be a lot of processing. You may want to tune the > >> query > >> > in a way to minimize overhead; someone else in the list may suggest = a > >> better > >> > strategy. > >> > > >> > > >> > -----Original Message----- > >> > From: Franklin Simmons [mailto:fsimmons@sccmediaserver.com] > >> > Sent: Friday, October 30, 2009 2:01 PM > >> > To: lucene-net-user@incubator.apache.org > >> > Subject: RE: Simple question > >> > > >> > Hi Andr=E9, > >> > > >> > In this case you simply sort on the field. This may suffice: > >> > > >> > Searcher searcher =3D new IndexSearcher(directory); > >> > > >> > Sort =3D new Sort(new SortField("another_field", SortField.AUTO, > false)); > >> > > >> > Hits hits =3D searcher.search(query,sort); > >> > > >> > > >> > You can limit the number of hits (e.g. to 5), but I won't get into > that > >> > here. > >> > > >> > > >> > Beyond SortField.AUTO, take a look at the SortField class to see > >> specific > >> > field types - the most interesting being SortField.CUSTOM. > >> > > >> > > >> > -----Original Message----- > >> > From: Andr=E9 Maldonado [mailto:andre.maldonado@gmail.com] > >> > Sent: Friday, October 30, 2009 1:46 PM > >> > To: lucene-net-user@incubator.apache.org > >> > Subject: Re: Simple question > >> > > >> > Hi Franklin. > >> > > >> > Wich query I use for this search (variable: query)? I don't want any > >> query, > >> > I just want the TOP 5 documents ordered by a field. > >> > > >> > Thank's > >> > > >> > "Ent=E3o aproximaram-se os que estavam no barco, e adoraram-no, dize= ndo: > >> =C9s > >> > verdadeiramente o Filho de Deus." (Mateus 14:33) > >> > > >> > > >> > On Fri, Oct 30, 2009 at 15:03, Franklin Simmons < > >> > fsimmons@sccmediaserver.com > >> > > wrote: > >> > > >> > > You can sort a search by multiple fields. I think you could try > >> > something > >> > > like this: > >> > > > >> > > Searcher searcher =3D new IndexSearcher(directory); > >> > > Sort =3D new Sort(new SortField[] { SortField.FIELD_SCORE, new > >> > > SortField("another_field") }; > >> > > Hits hits =3D searcher.search(query,sort); > >> > > > >> > > > >> > > -----Original Message----- > >> > > From: Andr=E9 Maldonado [mailto:andre.maldonado@gmail.com] > >> > > Sent: Friday, October 30, 2009 12:57 PM > >> > > To: lucene-net-user@incubator.apache.org > >> > > Subject: Simple question > >> > > > >> > > Hi. > >> > > > >> > > This can be a simple question, but I can't figure out the solution= . > >> > > > >> > > I need to search my index in something like "SELECT TOP 5 ... ORDE= R > BY > >> > > another_field". But this is an empty query because I want to searc= h > in > >> > all > >> > > documents. > >> > > > >> > > How can I do it? > >> > > > >> > > Thank's > >> > > > >> > > >> > > > > > --0016e646432c742f8c047779ffa9--