I experimented with the previous code, but no results are returned from the index. Someone can give me an example? I have been for some time trying to implement this functionality.
Thanks. 2013/8/6 David Miranda <david.b.mira...@gmail.com> > Do this with the BooleanQuery: > >> Query q1 = new QueryParser(Version.LUCENE_43, "label", analyzer >> ).parse(label); >> Query q2 = new QueryParser(Version.LUCENE_43, "abstract", analyzer >> ).parse(abstract); >> BooleanQuery bq = new BooleanQuery(); >> booleanQuery.add(q1,BooleanClause.Occur.MUST); >> booleanQuery.add(q2,BooleanClause.Occur.MUST); >> Hits hits = indexSearcher.search(booleanQuery); > > > This is right for what I want to do? > > Thanks. > > 2013/8/6 Ian Lea <ian....@gmail.com> > > The standard way is to combine the searches by label and abstract into >> one query. If using QueryParser a simple example would look something >> like label:aaa abstract:bbb abstract:ccc. You can get the same >> effect, with more flexibility, by building a BooleanQuery in code. >> >> Also consider using a Filter e.g. QueryWrapperFilter on a query for >> label:aaa with the query generated by QueryParser or direct >> construction of a TermQuery. See also CachingWrapperFilter if the >> index isn't constantly changing. >> >> >> -- >> Ian. >> >> >> On Tue, Aug 6, 2013 at 3:19 PM, David Miranda <david.b.mira...@gmail.com> >> wrote: >> > Hi, >> > >> > I have a Lucene index that has the fields label and abstract. >> > >> > I want to do is first do a search by label field, for this i use: >> > >> > TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_HITS, >> true >> >> ); >> >> searcher.search(q, collector); >> >> ScoreDoc[] hits = collector.topDocs().scoreDocs; >> > >> > >> > After the results of the first survey, I want to do a search in the >> > abstract field only in results obtained from the first survey. >> > >> > How i do this? >> > Thanks in advance. >> > >> > David >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> > > > -- > Cumprimentos, > David Miranda > -- Cumprimentos, David Miranda