diff --git a/modules/search/instant-search/lib/api.js b/modules/search/instant-search/lib/api.js index 0797cbbf8a28..0fa161568221 100644 --- a/modules/search/instant-search/lib/api.js +++ b/modules/search/instant-search/lib/api.js @@ -37,10 +37,10 @@ function generateAggregation( filter ) { }; } case 'taxonomy': { - let field = `taxonomy.${ filter.taxonomy }.slug`; + let field = `taxonomy.${ filter.taxonomy }.name.raw`; if ( filter.taxonomy === 'post_tag' ) { field = 'tag.slug'; - } else if ( filter.type === 'category' ) { + } else if ( filter.taxonomy === 'category' ) { field = 'category.slug'; } return { terms: { field, size: filter.count } }; @@ -116,7 +116,7 @@ function buildFilterObject( filterQuery ) { filter.bool.must.push( filterKeyToEsFilter.get( key )( item ) ); } else { // If key is not in the standard map, assume to be a custom taxonomy - filter.bool.must.push( { term: { [ `taxonomy.${ key }.slug` ]: item } } ); + filter.bool.must.push( { term: { [ `taxonomy.${ key }.name.raw` ]: item } } ); } } ); } );