Help Center> RES> User Guide> Managing a Data Source> Preparing an Offline Data Source

Preparing an Offline Data Source

When using RES to create a data source, you need to prepare basic data packages and upload them to OBS. If the nearline process is used, the tracing point logs of the service system must be converted to the format specified by RES and written to the corresponding DIS streams in real time. This section describes the data formats of the offline and nearline data sources of RES. You can prepare data by referring to this section. The basic data packages include:

User Data

Table 1 User data field description

Parameter

Type

Description

Mandatory

userId

String

Unique user ID

Yes

age

Long

Age

No

gender

String

Sex. Possible values are as follows:

  • male
  • female
  • unknown

No

location

Json

Geographical location information concerning a user, which is set according to site requirements and in the format of {"lat": latitude, "lon": longitude}. Example: "location": {"lat": 41.12, "lon": -71.34}.

No

tags

List[String]

User tag. Each tag is an independent element, such as "basketball" and "family".

No

interest_tags

List[String]

Interest tag, which is automatically updated by the system. This field is reserved by default.

No

extend

Json

Extended field. The key and value of the extended field are specified by users.

  • key: You can name the key based on service requirements. The value does not need to start with extend_.
  • value: You can input data in long, float, string, strArray, or location format.

No

Example of User Data

{
  "userId": "user0",
  "age": 22,
  "gender": "female",
  "location": {
    "lat": 28.268705,
    "lon": -144.70218
  },
  "tags": [
    "walk",
    "eat"
  ],
  "extend": {
    "extend_string": "walk",
    "extend_long": 1575968675501,
    "extend_float": 7.889256,
    "extend_strArray": [
      "football",
      "walk",
      "read",
      "eat"
    ]
  }
}

Item Data

Table 2 Item data field description

Parameter

Type

Description

Mandatory

itemId

String

Unique item ID

Yes

itemType

String

Item type, which can be used to control the diversity of recommendation result sets. The possible values are:

  • item
  • article
  • video
  • audio
  • image

Yes

category

String

The category of an item, such as "course" or "snacks", which is the basis for the scatter function.

No

status

Long

Whether an item can be recommended or pinned to the top. The default value is 0.

  • 0 indicates an item can be recommended.
  • 1 indicates an item cannot be recommended.
  • 2 indicates an item can be pinned to the top.

No

title

String

Title, which can be used for semantic analysis. If this parameter is not set, some algorithm effects will be lost.

No

score

Long

Weight of an item. A higher weight indicates a higher probability that the item is recommended. The value ranges from 1 to 100. If this parameter is not set, 1 is used by default.

No

publishTime

Long

The publishing time, in seconds and in Coordinated Universal Time (UTC). This parameter is highly recommended if timeless is crucial.

No

expireTime

Long

The expiry time, in seconds and in Coordinated Universal Time (UTC). If the current server time is later than the time specified by this parameter, the item will not be recommended. If this parameter is not set, the item or content never expires.

No

author

List[String]

Author information. One author corresponds to one element. You are advised to set this parameter in the information flow recommendation area.

No

content

String

Content description of an item, for example, introduction, abstract, or key part of the body. The value can contain up to 5,000 characters. If the value contains more than 5,000 characters, the excess characters will be truncated. If this parameter is not set, some algorithm effects will be lost.

No

tags

List[String]

Item tag. Each tag is an independent element,

No

location

Json

Geographical location of an item. The value is in the {"lat": latitude, "lon": longitude} format. Example: "location": {"lat": 41.12, "lon": -71.34}.

No

extend

Json

Extended field. The key and value of the extended field are specified by users.

  • key: You can name the key based on service requirements. The value does not need to start with extend_.
  • value: You can input data in long, float, string, strArray, or location format.

No

Example of Item Data

{
  "itemId": "item0",
  "itemType": "item",
  "category": "ceshi category",
  "status": 1,
  "score": 100,
  "publishTime": 1575110848,
  "expireTime": 1576441885,
  "author": [
    "author1"
  ],
  "tags": [
    "walk",
    "read",
    "ball"
  ],
  "location": {
    "lat": -15.56869,
    "lon": 107.15255
  },
  "extend": {
    "extend_string": "walk",
    "extend_long": 1575968675536,
    "extend_float": 6.182992,
    "extend_strArray": [
      "walk"
    ]
  }
}

Behavior Data

Table 3 Behavior data field description

Parameter

Type

Description

Mandatory

userId

String

User ID

Yes

itemType

String

Item type. Item is an object of a behavior.

Yes

itemId

String

Value of the object on which the behavior occurs. If the object of the behavior is an item, the value is the item ID.

Yes

actionType

String

Behavior type, which can be positive or negative.

NOTE:

Custom behavior type is not supported.

  • Positive behaviors include:

    click. You click an item. The default score is 0.3.

    collect. You add an item to the favorites. The default score is 0.5.

    search_click. You search for something. The default score is 0.4.

    comment. You make comments on an item. The default score is 0.2.

    share. You share an item with others. The default score is 0.5.

    like. You like an item. The default score is 0.8.

    consume. You consume an item. The default score is 1.

    use. You watch videos, listen to music, and read books. The default score is 0.6.

    download. You download something. The default score is 0.6.

    tip: You give a reward. The default score is 1.

    subscribe: You follow somebody or something. The default score is 0.7.

  • Negative behaviors include:

    view: You browse something. The default score is 0.1.

    dislike: You dislike an item. The default score is 0.8.

    uncollect: You remove an item from favorites. The default score is 0.4.

    use: You use something for less than a specified time period. The default score is 0.1.

Yes

actionMeasure

Int

Measurement of the behavior. The value is a positive integer ranging from 1 to 10. The default score of the behavior type is used as the measurement by default. The use field is used. You are advised to convert the value based on site requirements. For example, if a user watches a 15-second video for more than 10 seconds, the score is 7 points. If the user finishes watching the video, the score is 9 points.

Yes

actionTime

Long

Time when a behavior occurs, in seconds and in Coordinated Universal Time (UTC).

Yes

actionLocation

Json

Location of a behavior, including the latitude and longitude. The format is {"lat": latitude, "lon": longitude }. Example: "location": {"lat": 41.12, "lon": -71.34}.

No

sceneId

String

Recommendation scenario ID, which is used to differentiate scenarios.

No

traceId

String

Unique ID used to trace each recommendation item. The ID is used in effect evaluation.

No

flowId

String

ID of a flow, which is used to evaluate the effects of an online process flow. The flow ID is returned by the RES APIs to users. You need to write the flow ID to the user behavior logs.

No

Example of Behavior Data

{
  "userId": "user0",
  "itemType": "item",
  "itemId": "item0",
  "actionType": "view",
  "actionMeasure": 5,
  "actionTime": 1575857721
}