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
16 changes: 16 additions & 0 deletions whelk-core/src/main/groovy/whelk/search2/querytree/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ public List<ExpandedPath> getAltPaths(JsonLd jsonLd, Collection<String> rdfSubje
altPaths.add(this);
}

/*
FIXME:
Integral relations are generally not applied to records.
Bibliography is an exception: we need to search both meta.bibliography and hasInstance.meta.bibliography.
*/
if (altPaths.size() == 1) {
var path = altPaths.getFirst();
if (path.jsonForm().startsWith("meta.bibliography")) {
integralRelations.stream().filter(ir -> ir.name().equals("hasInstance"))
.map(hasInstance -> Stream.concat(Stream.of(hasInstance), path.path().stream()).toList())
.map(ExpandedPath::new)
.findFirst()
.ifPresent(altPaths::add);
}
}

return altPaths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FreeTextSpec extends Specification {
given:
Map boostSettings = [
"field_boost": [
"fields": [
"fields" : [
[
"name" : "field1",
"boost": 10
Expand All @@ -18,18 +18,19 @@ class FreeTextSpec extends Specification {
"boost": 20
]
],
"analyze_wildcard": true
"analyze_wildcard": true,
]
]
Map esQuery = new FreeText("something").toEs(new ESSettings.Boost(boostSettings).fieldBoost())

expect:
esQuery == [
"simple_query_string": [
"default_operator": "AND",
"query" : "something",
"analyze_wildcard": true,
"fields" : [
"default_operator" : "AND",
"query" : "something",
"analyze_wildcard" : true,
"quote_field_suffix": ".exact",
"fields" : [
"field1^10.0",
"field2^20.0"
]
Expand All @@ -41,34 +42,35 @@ class FreeTextSpec extends Specification {
given:
Map boostSettings = [
"field_boost": [
"fields": [
"fields" : [
[
"name" : "field1",
"boost": 10,
"name" : "field1",
"boost" : 10,
"script_score": [
"name" : "a function",
"function": "f1(_score)"
]
],
[
"name" : "field2",
"boost": 20,
"name" : "field2",
"boost" : 20,
"script_score": [
"name" : "a function",
"function": "f1(_score)"
]
],
[
"name" : "field3",
"boost": 10,
"name" : "field3",
"boost" : 10,
"script_score": [
"name" : "another function",
"function": "f2(_score)",
"apply_if": "condition"
]
]
],
"analyze_wildcard": true
"analyze_wildcard" : true,
"quote_field_suffix": ".exact"
]
]
Map esQuery = new FreeText("something").toEs(new ESSettings.Boost(boostSettings).fieldBoost())
Expand All @@ -84,10 +86,11 @@ class FreeTextSpec extends Specification {
],
"query" : [
"simple_query_string": [
"default_operator": "AND",
"query" : "something",
"analyze_wildcard": true,
"fields" : [
"default_operator" : "AND",
"query" : "something",
"analyze_wildcard" : true,
"quote_field_suffix": ".exact",
"fields" : [
"field1^10.0",
"field2^20.0",
"field3^0.0"
Expand All @@ -103,10 +106,11 @@ class FreeTextSpec extends Specification {
],
"query" : [
"simple_query_string": [
"default_operator": "AND",
"query" : "something",
"analyze_wildcard": true,
"fields" : [
"default_operator" : "AND",
"query" : "something",
"analyze_wildcard" : true,
"quote_field_suffix": ".exact",
"fields" : [
"field1^0.0",
"field2^0.0",
"field3^10.0"
Expand All @@ -124,7 +128,7 @@ class FreeTextSpec extends Specification {
given:
Map boostSettings = [
"field_boost": [
"fields": [
"fields" : [
[
"name" : "field1",
"boost": 10
Expand All @@ -134,8 +138,8 @@ class FreeTextSpec extends Specification {
"boost": 20
],
[
"name" : "field3",
"boost": 10,
"name" : "field3",
"boost" : 10,
"script_score": [
"name" : "a function",
"function": "f(_score)"
Expand All @@ -153,10 +157,11 @@ class FreeTextSpec extends Specification {
'should': [
[
"simple_query_string": [
"default_operator": "AND",
"query" : "something",
"analyze_wildcard": true,
"fields" : [
"default_operator" : "AND",
"query" : "something",
"analyze_wildcard" : true,
"quote_field_suffix": ".exact",
"fields" : [
"field1^10.0",
"field2^20.0",
"field3^0.0"
Expand All @@ -170,10 +175,11 @@ class FreeTextSpec extends Specification {
],
"query" : [
"simple_query_string": [
"default_operator": "AND",
"query" : "something",
"analyze_wildcard": true,
"fields" : [
"default_operator" : "AND",
"query" : "something",
"analyze_wildcard" : true,
"quote_field_suffix": ".exact",
"fields" : [
"field1^0.0",
"field2^0.0",
"field3^10.0"
Expand Down
Loading