Imrove whatsaround query
By introducing a property path allowing a number of location properties,
including an optional won:seeks.
@@ -622,63 +622,28 @@ function isSparqlVariable(str) {
//TODO should return a context-def as well
export function generateWhatsAroundQuery(latitude, longitude) {
- return (
- `PREFIX won: <http://purl.org/webofneeds/model#>
+ return `PREFIX won: <http://purl.org/webofneeds/model#>
PREFIX s: <http://schema.org/>
PREFIX geo: <http://www.bigdata.com/rdf/geospatial#>
PREFIX geoliteral: <http://www.bigdata.com/rdf/geospatial/literals/v1#>
SELECT DISTINCT ?result ?score WHERE {
bind (if(?location_geoDistance = 0, 1, 1/?location_geoDistance) as ?score)
- {
- SELECT DISTINCT ?result ?location_geoDistance WHERE {
- ?result <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> won:Need.
- ?result won:isInState won:Active .
- ?result won:hasLocation ?location.
- ?location s:geo ?location_geo.
- SERVICE geo:search {
- ?location_geo geo:search "inCircle".
- ?location_geo geo:searchDatatype geoliteral:lat-lon.
- ?location_geo geo:predicate won:geoSpatial.
- ?location_geo geo:spatialCircleCenter "` +
- latitude +
- `#` +
- longitude +
- `".
- ?location_geo geo:spatialCircleRadius "10".
- ?location_geo geo:distanceValue ?location_geoDistance.
- }
- FILTER NOT EXISTS { ?result won:hasFlag won:NoHintForCounterpart }
- FILTER NOT EXISTS { ?result won:hasFlag won:WhatsNew }
- FILTER NOT EXISTS { ?result won:hasFlag won:WhatsAround }
- }
- }
- UNION {
- SELECT DISTINCT ?result ?location_geoDistance WHERE {
?result <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> won:Need.
?result won:isInState won:Active .
- ?result won:seeks ?seeks.
- ?seeks won:hasLocation ?location.
+ ?result won:seeks?/(won:hasLocation|s:jobLocation|s:location|s:fromLocation|s:toLocation) ?location.
?location s:geo ?location_geo.
SERVICE geo:search {
?location_geo geo:search "inCircle".
?location_geo geo:searchDatatype geoliteral:lat-lon.
?location_geo geo:predicate won:geoSpatial.
- ?location_geo geo:spatialCircleCenter "` +
- latitude +
- `#` +
- longitude +
- `".
+ ?location_geo geo:spatialCircleCenter "${latitude}#${longitude}".
?location_geo geo:spatialCircleRadius "10".
?location_geo geo:distanceValue ?location_geoDistance.
}
FILTER NOT EXISTS { ?result won:hasFlag won:NoHintForCounterpart }
FILTER NOT EXISTS { ?result won:hasFlag won:WhatsNew }
FILTER NOT EXISTS { ?result won:hasFlag won:WhatsAround }
- }
- }
- }
- ORDER BY desc(?score)`
- );
+ }`;
}
export function generateWhatsNewQuery() {
@@ -699,6 +664,5 @@ export function generateWhatsNewQuery() {
FILTER NOT EXISTS { ?result won:hasFlag won:NoHintForCounterpart }
FILTER NOT EXISTS { ?result won:hasFlag won:WhatsNew }
FILTER NOT EXISTS { ?result won:hasFlag won:WhatsAround }
- }
- ORDER BY DESC(?created)`;
+ }`;
}
