Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Geospatial range index scoring example in MarkLogic 7.0-1
{
"options": {
"debug": false,
"transform-results": {
"apply": "raw"
},
"constraint": [{
"name": "stars",
"range": {
"type": "xs:int",
"element": {
"name": "stars",
"ns": "http://marklogic.com/xdmp/json/basic"
}
}
}, {
"name": "location",
"geo-elem-pair": {
"parent": {
"name": "location",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"lat": {
"name": "lat",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"lon": {
"name": "lon",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"geo-option": ["units=miles", "coordinate-system=wgs84"],
"heatmap": {
"n": 51.52584800198629,
"s": 51.49657509562668,
"w": -0.2003335857910146,
"e": -0.039315214208986225,
"latdivs": 5,
"londivs": 15
}
}
}],
"default-suggestion-source": [],
"additional-query": [],
"operator": [],
"page-length": 10,
"return-metrics": true,
"return-qtext": true,
"return-query": false,
"return-results": true,
"return-similar": false,
"search-option": [],
"sort-order": [{
"direction": "descending",
"score": null,
"annotation": ["Relevancy (Descending)"]
}, {
"direction": "ascending",
"type": "xs:int",
"json-key": "stars"
}, {
"direction": "descending",
"type": "xs:int",
"json-key": "stars"
}],
"suggestion-source": []
}
}
{
"snippet-format": "raw",
"total": 7,
"start": 1,
"page-length": 10,
"results": [{
"index": 1,
"uri": "/attractions/6",
"path": "fn:doc(\"/attractions/6\")",
"score": 6494208,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F6",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "The London Eye",
"location": {
"lat": 51.5034,
"lon": -0.119519
},
"stars": 5,
"description": "Great views"
}
}, {
"index": 2,
"uri": "/attractions/2",
"path": "fn:doc(\"/attractions/2\")",
"score": 5332992,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F2",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "Houses of Parliament",
"location": {
"lat": 51.499503,
"lon": -0.124357
},
"stars": 3,
"description": "Seat of power"
}
}, {
"index": 3,
"uri": "/attractions/5",
"path": "fn:doc(\"/attractions/5\")",
"score": 5117952,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F5",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "St Paul's Cathedral",
"location": {
"lat": 51.513679,
"lon": -0.09956
},
"stars": 2,
"description": "Big Cathedral"
}
}, {
"index": 4,
"uri": "/attractions/7",
"path": "fn:doc(\"/attractions/7\")",
"score": 4859904,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F7",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "Oxford Street",
"location": {
"lat": 51.51522,
"lon": -0.14188
},
"stars": 3,
"description": "Lots of Shops"
}
}, {
"index": 5,
"uri": "/attractions/3",
"path": "fn:doc(\"/attractions/3\")",
"score": 4386816,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F3",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "Buckingham Palace",
"location": {
"lat": 51.501364,
"lon": -0.14189
},
"stars": 3,
"description": "Tours available"
}
}, {
"index": 6,
"uri": "/attractions/1",
"path": "fn:doc(\"/attractions/1\")",
"score": 3182592,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F1",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "Tower of London",
"location": {
"lat": 51.508112,
"lon": -0.075949
},
"stars": 4,
"description": "Home of the Crown Jewels"
}
}, {
"index": 7,
"uri": "/attractions/4",
"path": "fn:doc(\"/attractions/4\")",
"score": 2795520,
"confidence": 1,
"fitness": 1,
"href": "/v1/documents?uri=%2Fattractions%2F4",
"mimetype": "application/json",
"format": "json",
"content": {
"title": "London Zoo",
"location": {
"lat": 51.535736,
"lon": -0.155679
},
"stars": 2,
"description": "Off the map, far from center."
}
}],
"facets": {
"stars": {
"type": "xs:int",
"facetValues": [{
"name": "2",
"count": 2,
"value": 2
}, {
"name": "3",
"count": 3,
"value": 3
}, {
"name": "4",
"count": 1,
"value": 4
}, {
"name": "5",
"count": 1,
"value": 5
}]
},
"location": {
"boxes": [{
"count": 1,
"s": 51.5014,
"w": -0.14189,
"n": 51.5014,
"e": -0.14189
}, {
"count": 1,
"s": 51.4995,
"w": -0.124357,
"n": 51.4995,
"e": -0.124357
}, {
"count": 1,
"s": 51.5034,
"w": -0.119519,
"n": 51.5034,
"e": -0.119519
}, {
"count": 1,
"s": 51.5081,
"w": -0.075949,
"n": 51.5081,
"e": -0.075949
}, {
"count": 1,
"s": 51.5137,
"w": -0.09956,
"n": 51.5137,
"e": -0.09956
}, {
"count": 1,
"s": 51.5152,
"w": -0.14188,
"n": 51.5152,
"e": -0.14188
}, {
"count": 1,
"s": 51.5357,
"w": -0.155679,
"n": 51.5357,
"e": -0.155679
}]
}
},
"metrics": {
"query-resolution-time": "PT0.655852S",
"facet-resolution-time": "PT0.152456S",
"snippet-resolution-time": "PT0.004929S",
"total-time": "PT1.062507S"
}
}
{
"query": {
"and-query": [{
"query": {
"and-query": [{
"collection-query": {
"uri": "attractions"
}
}, {
"geo-elem-pair-query": {
"parent": {
"name": "location",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"lat": {
"name": "lat",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"lon": {
"name": "lon",
"ns": "http://marklogic.com/xdmp/json/basic"
},
"geo-option": ["score-function=reciprocal", "units=miles"],
"circle": {
"radius": 20,
"point": [{
"latitude": 51.5112139,
"longitude": -0.1198244
}]
}
}
}]
}
}]
}
}
@eedeebee

This comment has been minimized.

Copy link

eedeebee commented Jan 15, 2014

This gist would look a bit nicer if the filenames ended in .json (or you mark the correct content type in the drop down).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.