Still can not implement this feature. Previously to perform a search in the
'label', I used the following code that worked:

Query q = new QueryParser(Version.LUCENE_43, "label", analyzer
> ).parse(label);
> searcher.search(q, collector);
> ScoreDoc[] hits = collector.topDocs().scoreDocs;

But with BooleanQuery does not work. What I want is the result of those
TopDocs, do the search but in the 'abstract' to filter. Has anyone
implemented something similar?


2013/8/7 Ian Lea <ian....@gmail.com>

> Your BooleanQuery code looks fine.  Do the label and abstract searches
> work independently?  Are there docs that match both searches? There
> are tips on non-working searches in the FAQ at
>
> http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_.2F_incorrect_hits.3F
>
> If that doesn't help I suggest you post the smallest possible
> self-contained example that shows the problem.
>
>
> --
> Ian.
>
>
> On Tue, Aug 6, 2013 at 9:55 PM, David Miranda <david.b.mira...@gmail.com>
> wrote:
> > 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


-- 
Cumprimentos,
David Miranda

Reply via email to