You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Matt Hicks <ma...@outr.com> on 2016/12/05 23:55:14 UTC

Facet DrillDown Exclusion

I'm currently drilling down adding a facet path, but I'd like to be able to
do the same as a NOT query.  Is there any way to do an exclusion drill down
on a facet to exclude docs that match the facet while including all others?

Thanks

Re: Facet DrillDown Exclusion

Posted by Matt Hicks <ma...@outr.com>.
Thanks, that did the trick!

On Tue, Dec 6, 2016 at 8:58 AM Shai Erera <se...@gmail.com> wrote:

> Hey Matt,
>
> You basically don't need to use DDQ in that case. You can construct a
> BooleanQuery with a MUST_NOT clause for filter out the facet path. Here's a
> short code snippet:
>
> String indexedField = config.getDimConfig("Author").indexFieldName; // Find
> the field of the "Author" facet
> Query q = new BooleanQuery.Builder()
>   .add(new MatchAllDocsQuery(), Occur.MUST) // here you would usually use a
> different query
>   .add(new TermQuery(DrillDownQuery.term(indexedField, "Author", "Lisa")),
> Occur.MUST_NOT) // do not match documents with "Author/Lisa" in their
> facets
>   .build();
> searcher.search(q, 10);
>
> Hope this helps
>
> Shai
>
> On Tue, Dec 6, 2016 at 1:55 AM Matt Hicks <ma...@outr.com> wrote:
>
> > I'm currently drilling down adding a facet path, but I'd like to be able
> to
> > do the same as a NOT query.  Is there any way to do an exclusion drill
> down
> > on a facet to exclude docs that match the facet while including all
> others?
> >
> > Thanks
> >
>

Re: Facet DrillDown Exclusion

Posted by Shai Erera <se...@gmail.com>.
Hey Matt,

You basically don't need to use DDQ in that case. You can construct a
BooleanQuery with a MUST_NOT clause for filter out the facet path. Here's a
short code snippet:

String indexedField = config.getDimConfig("Author").indexFieldName; // Find
the field of the "Author" facet
Query q = new BooleanQuery.Builder()
  .add(new MatchAllDocsQuery(), Occur.MUST) // here you would usually use a
different query
  .add(new TermQuery(DrillDownQuery.term(indexedField, "Author", "Lisa")),
Occur.MUST_NOT) // do not match documents with "Author/Lisa" in their facets
  .build();
searcher.search(q, 10);

Hope this helps

Shai

On Tue, Dec 6, 2016 at 1:55 AM Matt Hicks <ma...@outr.com> wrote:

> I'm currently drilling down adding a facet path, but I'd like to be able to
> do the same as a NOT query.  Is there any way to do an exclusion drill down
> on a facet to exclude docs that match the facet while including all others?
>
> Thanks
>