Skip to content

Commit

Permalink
Merge pull request #98 from dbmi-pitt/tjmadonna/hierarchy-facet-fix
Browse files Browse the repository at this point in the history
Tjmadonna/hierarchy facet fix
  • Loading branch information
maxsibilla authored Sep 25, 2024
2 parents fed440b + d73d631 commit f6cb332
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions components/core/HierarchicalCheckboxOptionFacet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const HierarchicalCheckboxOptionFacet = ({
const [isExpanded, setIsExpanded] = useState(false)

const getOptionCheckedState = () => {
let checked = true
let checked = false
for (const subval of option.subvalues) {
if (!filterExists(field, subval.value)) {
checked = false
if (filterExists(field, subval.value)) {
checked = true
break
}
}
Expand Down Expand Up @@ -63,6 +63,10 @@ const HierarchicalCheckboxOptionFacet = ({
setIsExpanded(!isExpanded)
}

if (option.subvalues.length === 0) {
return null
}

return (
<div className='d-flex flex-column align-items-start w-100'>
{/* Label and checkbox */}
Expand Down
13 changes: 7 additions & 6 deletions lib/search-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,14 @@ export function es_query_builder(request, queryConfig) {
let post_filter_agg = null
const includeExistAggs = {}
FILTERS.forEach((f) => {
//log.info(f[1])
let field = f[1].field + '.keyword'
let values = f[1].values
const values = f[1].values

let filterBoolQuery = esb.boolQuery();
const filterBoolQuery = esb.boolQuery();

values.forEach((v) => {
var facet_info = checkFilterType(f[1].field, FACETS)
const facet_info = checkFilterType(f[1].field, FACETS)
if (facet_info[1] && facet_info[1]["type"] === 'range') {
var element = createRangeQuery(v, facet_info)
const element = createRangeQuery(v, facet_info)

// If the field is a disjunctive facet and multiple items are selected we need to wrap those options
// in a `should` boolean query
Expand All @@ -107,6 +105,9 @@ export function es_query_builder(request, queryConfig) {
}
includeExistAggs[f[1].field] = [v]
} else {
const name = f[1].field
const field = queryConfig.facets[name].field

// If the field is a disjunctive facet and multiple items are selected we need to wrap those options
// in a `should` boolean query
if (values.length > 1) {
Expand Down

0 comments on commit f6cb332

Please sign in to comment.