Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static org.elasticsearch.index.query.QueryBuilders.multiMatchQuery;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -242,12 +241,7 @@ public BoolQueryBuilder buildQuery(String queryTerm, String category, Multivalue

// apply filters if a category has been set
if (StringUtils.isNotEmpty(category)) {
if (Category.ALLELE.getName().equals(category)) {
bool.filter(termsQuery("category", Category.ALLELE.getName(), Category.VARIANT.getName()));
} else {
bool.filter(new TermQueryBuilder("category", category));
}

bool.filter(new TermQueryBuilder("category", category));
// expand the map of lists and add each key,value pair as filters
filters.entrySet().stream().forEach(entry -> entry.getValue().stream().forEach(value -> {
if (value.charAt(0) == '-') {
Expand Down Expand Up @@ -338,7 +332,7 @@ public void addRelatedDataLinks(Map<String, Object> result) {
links.add(getRelatedDataLink(Category.GENE.getName(), "diseasesWithParents", nameKey));
links.add(getRelatedDataLink(Category.ALLELE.getName(), "diseasesWithParents", nameKey));
links.add(getRelatedDataLink(Category.MODEL.getName(), "diseasesWithParents", nameKey));
} else if (StringUtils.equals(category, Category.ALLELE.getName()) && StringUtils.equals((String) result.get("alterationType"), "allele")) {
} else if (StringUtils.equals(category, Category.ALLELE.getName())) {
links.add(getRelatedDataLink(Category.DISEASE.getName(), "alleles", nameKey));
links.add(getRelatedDataLink(Category.GENE.getName(), "alleles", nameKey));
links.add(getRelatedDataLink(Category.MODEL.getName(), "alleles", nameKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Map;
import java.util.Set;

import org.alliancegenome.es.model.search.AggDocCount;
import org.alliancegenome.es.model.search.AggResult;
import org.alliancegenome.es.model.search.Category;
import org.elasticsearch.action.search.SearchResponse;
Expand Down Expand Up @@ -96,6 +95,7 @@ public class SearchHelper {
add("alterationType");
add("variantType");
add("molecularConsequence");
add("diseasesAgrSlim");
add("genes");
}
});
Expand Down Expand Up @@ -338,7 +338,6 @@ public ArrayList<AggResult> formatAggResults(String category, SearchResponse res
Terms aggs = res.getAggregations().get("categories");
Set<String> acceptableKeys = new HashSet<>(categoryFilters.keySet());
AggResult ares = new AggResult("category", aggs, acceptableKeys);
mergeAlleleVariantBuckets(ares);
orderCategoryBuckets(ares);
ret.add(ares);
} else {
Expand All @@ -354,24 +353,6 @@ public ArrayList<AggResult> formatAggResults(String category, SearchResponse res
return ret;
}

/**
* Merge the "allele_search_results" and "variant_search_results" aggregation buckets into a single "allele_search_results" bucket.
*/
private void mergeAlleleVariantBuckets(AggResult aggResult) {
long combinedCount = 0;
List<AggDocCount> toRemove = new ArrayList<>();
for (AggDocCount bucket : aggResult.getValues()) {
if (bucket.getKey().equals(Category.ALLELE.getName()) || bucket.getKey().equals(Category.VARIANT.getName())) {
combinedCount += bucket.getTotal();
toRemove.add(bucket);
}
}
aggResult.getValues().removeAll(toRemove);
if (combinedCount > 0) {
aggResult.getValues().add(new AggDocCount(Category.ALLELE.getName(), combinedCount));
}
}

private void orderCategoryBuckets(AggResult aggResult) {
aggResult.getValues().sort((a, b) -> Long.compare(b.getTotal(), a.getTotal()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public List<AlleleSearchResultDocument> convert(List<AlleleSummaryDocument> alle
searchDoc.setGenes(List.of(geneSymbol));
}

if (doc.getGeneSynonyms() != null && !doc.getGeneSynonyms().isEmpty()) {
searchDoc.setGeneSynonyms(doc.getGeneSynonyms());
}

if (doc.getCrossReference() != null && doc.getCrossReference().getReferencedCurie() != null) {
searchDoc.setModCrossRefCompleteUrl(doc.getCrossReference().getReferencedCurie());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public AlleleSearchResultDocument() {
private Set<String> constructRegulatoryRegion;
private Set<String> constructKnockdownComponent;
private List<String> synonyms;
private Set<String> geneSynonyms;
private List<String> secondaryIds;
private List<String> genes;
private List<String> diseases;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
<checkstyle.version>10.17.0</checkstyle.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<curation.version>v0.47.31</curation.version>
<curation.version>v0.47.32</curation.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
Loading