Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vocab guided query expansion #1544

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
7 changes: 1 addition & 6 deletions rest/src/main/groovy/whelk/rest/api/SearchUtils2.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Map<String, Object> doSearch(Map<String, String[]> queryParameters) throws Inval
}

qTree.addFilters(queryParams, appParams);
qTree.setOutsetType(disambiguate);

Map<String, Object> esQueryDsl = getEsQueryDsl(qTree, queryParams, appParams.statsRepr);

Expand Down Expand Up @@ -96,7 +95,7 @@ private Map<String, Object> getEsQueryDsl(QueryTree queryTree, QueryParams query
}
}

queryDsl.put("aggs", Aggs.buildAggQuery(statsRepr, disambiguate, queryTree.getOutsetType(), queryUtil::getNestedPath));
queryDsl.put("aggs", Aggs.buildAggQuery(statsRepr, disambiguate, queryTree.collectRulingTypes(disambiguate), queryUtil::getNestedPath));
queryDsl.put("track_total_hits", true);

if (queryParams.debug.contains(QueryParams.Debug.ES_SCORE)) {
Expand All @@ -109,10 +108,6 @@ private Map<String, Object> getEsQueryDsl(QueryTree queryTree, QueryParams query
}

private Map<String, Object> getEsQuery(QueryTree queryTree, List<String> boostFields) {
if (!boostFields.isEmpty()) {
return queryTree.toEs(queryUtil, disambiguate, boostFields);
}
boostFields = queryUtil.esBoost.getBoostFields(queryTree.collectTypes());
return addConstantBoosts(queryTree.toEs(queryUtil, disambiguate, boostFields));
}

Expand Down
5 changes: 3 additions & 2 deletions whelk-core/src/main/groovy/whelk/search2/Aggs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import whelk.search2.querytree.PropertyValue;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -34,7 +35,7 @@ public record Bucket(String value, int count) {

public static Map<String, Object> buildAggQuery(AppParams.StatsRepr statsRepr,
Disambiguate disambiguate,
OutsetType outsetType,
Collection<String> types,
Function<String, Optional<String>> getNestedPath) {
if (statsRepr.isEmpty()) {
return Map.of(JsonLd.TYPE_KEY,
Expand All @@ -46,7 +47,7 @@ public static Map<String, Object> buildAggQuery(AppParams.StatsRepr statsRepr,

for (AppParams.Slice slice : statsRepr.sliceList()) {
Property property = slice.property();
Node expanded = property.expand(disambiguate, outsetType);
Node expanded = property.expand(disambiguate, types);
List<Node> altPaths = expanded instanceof Or ? expanded.children() : List.of(expanded);

for (Node n : altPaths) {
Expand Down
Loading
Loading