Skip to content

Commit

Permalink
Merge pull request #1270 from hubmapconsortium/collectionRefine
Browse files Browse the repository at this point in the history
Collection Groups Search by Dataset
  • Loading branch information
yuanzhou authored Nov 6, 2023
2 parents 30bca01 + 2fa7a4a commit f4b56a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/src/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,20 @@ export const EXCLUDE_USER_GROUPS = ["2cf25858-ed44-11e8-991d-0e368f3075e8", "577

// this is a list of fields for the keyword search. note: must ID fields need to use .keyword
export const ES_SEARCHABLE_FIELDS = [
"created_by_user_displayname",
"created_by_user_email",
"dataset_info",
"datasets.group_uuid",
"description.keyword",
"hubmap_id.keyword",
"submission_id.keyword",
"display_doi.keyword",
"lab_donor_id.keyword",
"display_subtype.keyword",
"hubmap_id.keyword",
"lab_dataset_id.keyword",
"lab_donor_id.keyword",
"lab_name.keyword",
"lab_tissue_sample_id.keyword",
"lab_donor_id.keyword",
"lab_dataset_id.keyword",
"created_by_user_displayname",
"created_by_user_email",
"dataset_info"
];
"submission_id.keyword",
];

// this list is for wildcard searchable fields
export const ES_SEARCHABLE_WILDCARDS = [
Expand Down
10 changes: 8 additions & 2 deletions src/src/service/search_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function api_search2(params, auth, from, size, fields) {
*
*/
export function search_api_filter_es_query_builder(fields, from, size, colFields) {

console.debug('%c⊙', 'color:#00ff7b', "fields", fields);
let requestBody = esb.requestBodySearch();
let boolQuery = "";
if (fields["keywords"] && fields["keywords"].indexOf("*") > -1) { // if keywords contain a wildcard
Expand All @@ -128,7 +128,13 @@ export function search_api_filter_es_query_builder(fields, from, size, colFields
if (fields["group_name"]) {
boolQuery.must(esb.matchQuery("group_name.keyword", fields["group_name"]));
} else if (fields["group_uuid"]) {
boolQuery.must(esb.matchQuery("group_uuid.keyword", fields["group_uuid"]));
// this'll be from the dropdown,
// if its a collection, we wanna search the datasets of it, not it itself
if (fields["entity_type"] === 'Collection') {
boolQuery.must(esb.matchQuery("datasets.group_uuid.keyword", fields["group_uuid"]));
} else {
boolQuery.must(esb.matchQuery("group_uuid.keyword", fields["group_uuid"]));
}
}
// was specimen types selected
if (fields["sample_category"]) {
Expand Down

0 comments on commit f4b56a0

Please sign in to comment.