Service to categorize records of a given index.

post

/spatialviewer/api/v1/spark/categorize

This service categorizes records of a given index and returns a result that have the needed information to be display on maps. The possible categorization operations can be used as following:
  • The count operation does not require any attribute name defined on the RenderingOptions.
  • For number and text attributes the average can be used.
  • The average in case of numerical attribute will render depending on the average value per template feature, for textual values the rending will be done depending on the text value that is more numerous in the template feature.
  • The sum is only available for numerical attributes.
  • The count will create the view based on the number of records per template feature.

Request

Supported Media Types
Query Parameters
  • if true the operation is runned asynchronously.
    Default Value: false
  • The name of the attribute to render the color of the categorization items depending on his value.
  • The categorization operation. The possible values are average, count and sum. The default value is average.
    Default Value: average
  • The index path in HDFS.
  • if true the attribute attributeName is numerical. If false the attribute attributeName is handle as an attribute with textual values.
    Default Value: false
  • Set the limits as JSON string. For example: [{ "lowerLimit": 1, "upperLimit": 2}, { "lowerLimit": 2, "upperLimit": 3}]. The relation with the colors array has to be 1-1. Optional parameter.
  • The maximum possible value of the categorization items. Optional parameter.
    Default Value: 0
  • The minimum possible value of the categorization items. Optional parameter.
    Default Value: 0
  • The job output path.
  • Sets the possible colors of the categorization items. By default the colors are #225d98, #D3D3D3, #ffa500, #600000. Optional parameter.
  • The template file, for example world_countries.json. The available templates can be found in the folder /opt/oracle/oracle-spatial-graph/spatial/web-server/spatialviewer/templates/.
  • Sets the possible text attribute's values sepated by commas. The relation with the colors array has to be 1-1, that is if 5 possible values are defined then 5 colors have to be defined. For example: very high,high,medium,low,very low. Optional parameter.
  • Double value that represents the tolerance used when performing spatial operations. For example 0.05.
    Default Value: 0.05
Back to Top

Response

Supported Media Types

200 Response

Successful request.

The response contains the location of the results in HDFS.

Additionally When the job finishes the results will be saved in the folder categorization_results contained in the SpatialViewer local working directory (see SpatialViewer configuration).
Body ()
Root Schema : SparkCatJobResponse
Type: object
Show Source

202 Response

accepted asynchronous request
Body ()
Root Schema : AsyncSparkCatJobResponse
Type: object
Show Source
Back to Top

Examples

The following example shows how to perform a categorization by submitting a POST request on the REST resource using cURL.

curl -v -X POST "http://localhost:8045/spatialviewer/api/v1/spark/categorize?indexPath=/user/oracle/tweetsJanuary&outputPath=/user/oracle/spatialviewer/CatTweets&isRenderingByAttributeNumber=true&attributeName=followers_count&templateFile=world_countries.json" -H  "accept: application/json" 

Example of Response Header

The following shows an example of the response header.

HTTP/1.1 200 OK Date: Wed, 15 Nov 2017 17:50:38 GMT Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, DELETE, PUT Access-Control-Allow-Headers: Content-Type, Accept Transfer-Encoding: chunked  Content-Type: application/json

Example of Response Body

The following example shows the contents of the response body in JSON format:

{"status" : "success", "title" : "Categorize job.", "o:successCode" : "SV-05015", "response" : "hdfs://system4.example.com:8020/user/oracle/spatialviewer/CatTweets"} 
Back to Top