Updated on 2022-08-09 GMT+08:00

Querying Vertices That Meet Filter Criteria

Function

This API is used to query vertices that meet filter criteria.

URI

  • URI format
    POST /ges/v1.0/{project_id}/graphs/{graph_name}/vertices/action?action_id=query
  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID, which is used for resource isolation. For details, see Obtaining a Project ID.

    graph_name

    Yes

    String

    Graph name

Request

  • Request example
    POST https://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/vertices/action?action_id=query  
    
    {
       "offset":0,
       "limit":2,
       "labels": ["movies",
                 "user"],
       "vertexFilters":[{
          "propertyName":"Age",
          "predicate":"=", 
          "values":["18-24"]
          }
       ]
    } 

    SERVER_URL: Address for accessing a graph. For details about its value, see Constraints of Using Service Plane APIs.

  • Parameter description
    Table 2 Request body parameter description

    Parameter

    Mandatory

    Type

    Description

    labels

    Either labels or vertexFilters is mandatory.

    String

    Filter criteria of the vertex type

    vertexFilters

    Either labels or vertexFilters is mandatory.

    Json

    Filter criteria, in JSONArray format. Vertices are filtered by property.

    offset

    No

    Integer

    Start position of the request

    limit

    No

    Integer

    Maximum number of resources displayed on a single page. The default value is 10.

    sorts

    No

    Json

    Result sorting property, in JSONArray format

    Table 3 sorts parameter description

    Parameter

    Mandatory

    Type

    Description

    key

    Either Key or propertyName is mandatory.

    String

    Possible values are id, label, and property. These values indicate that IDs, labels, or properties are sorted.

    propertyName

    Either Key or propertyName is mandatory.

    String

    Property name

    orderValue

    No

    String

    Possible values are incr and decr, which indicate ascending and descending order respectively. The default value is incr.

    Table 4 vertexFilters parameter structure

    Parameter

    Mandatory

    Type

    Description

    propertyName

    Yes

    String

    Property name

    predicate

    Yes

    String

    Logical relationship. Possible values are =, <, >, <=, >=, range, has, hasNot.

    values

    No

    String

    Property value.

    type

    No

    String

    Logical relationship of filter criteria. Possible values are and and or. The default value is and.

  • Example 1 for vertexFilters
    [
     {
       "propertyName":"Gender",
       "predicate":"=",
       "values":["F"]
     },
     {
       "propertyName":"Age",
       "predicate":"range", 
       "values":["18-24","56+"],
       "type":"or"
     }
    ]

Response

Table 5 Parameter description

Parameter

Mandatory

Type

Description

errorMessage

No

String

System prompt. If execution succeeds, this parameter may be left blank. If execution fails, this parameter is used to display the error message.

errorCode

No

String

System prompt. If execution succeeds, this parameter may be left blank. If execution fails, this parameter is used to display the error code.

job_id

No

String

ID of the vertex query job. This parameter is left blank when the request fails.

NOTE:

You can view the job execution status and obtain the return result by querying the job ID. For details, see Querying Job Status on the Service Plane.

  • Response example (successful request)
    Http Status Code: 200
    {
        "jobId": "03e774f5-29ea-4187-9508-5435f3892ead016886200",
        "jobType": 1
    }
  • Response example (failed request)
    Http Status Code: 400
    {
        "errorMessage": "Bad Request, parameter labels and vertexFilters cannot all be null",
        "errorCode": "GES.8203"
    }

Return Value

  • Normal

    200

  • Abnormal
    Table 6 Return code for failed requests

    Return Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No operation permission.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    Service internal error.

    503 Service Unavailable

    Service unavailable.