Skip to content

Commit

Permalink
Merge pull request #409 from geonetwork/intersect-geom-boost
Browse files Browse the repository at this point in the history
Datahub: Boost results with intersecting geom
  • Loading branch information
tkohr authored Jan 16, 2023
2 parents 885fc96 + 2c8ce9b commit 93744ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('ElasticsearchService', () => {
type: 'Polygon',
}
})
it('adds a criteria for intersecting with it and boosting on geoms within', () => {
it('adds boosting of 7 for intersecting with it and boosting of 10 on geoms within', () => {
const query = service['buildPayloadQuery'](
{
Org: {
Expand All @@ -225,16 +225,7 @@ describe('ElasticsearchService', () => {
)
expect(query).toEqual({
bool: {
filter: [
{
geo_shape: {
geom: {
shape: geojsonPolygon,
relation: 'intersects',
},
},
},
],
filter: [],
must: [
{
terms: {
Expand Down Expand Up @@ -281,6 +272,15 @@ describe('ElasticsearchService', () => {
boost: 10.0,
},
},
{
geo_shape: {
geom: {
shape: geojsonPolygon,
relation: 'intersects',
},
boost: 7.0,
},
},
],
},
})
Expand Down
31 changes: 17 additions & 14 deletions libs/util/shared/src/lib/elasticsearch/elasticsearch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,26 @@ export class ElasticsearchService {
})
}
if (geometry) {
should.push({
geo_shape: {
geom: {
shape: geometry,
relation: 'within',
should.push(
{
geo_shape: {
geom: {
shape: geometry,
relation: 'within',
},
boost: 10.0,
},
boost: 10.0,
},
})
filter.push({
geo_shape: {
geom: {
shape: geometry,
relation: 'intersects',
{
geo_shape: {
geom: {
shape: geometry,
relation: 'intersects',
},
boost: 7.0,
},
},
})
}
)
}

return {
Expand Down

0 comments on commit 93744ce

Please sign in to comment.