Facet DrillDown Exclusion

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Facet DrillDown Exclusion

Matt Hicks
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
Reply | Threaded
Open this post in threaded view
|

Re: Facet DrillDown Exclusion

Shai Erera
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 <[hidden email]> 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
>
Reply | Threaded
Open this post in threaded view
|

Re: Facet DrillDown Exclusion

Matt Hicks
Thanks, that did the trick!

On Tue, Dec 6, 2016 at 8:58 AM Shai Erera <[hidden email]> 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 <[hidden email]> 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
> >
>