跳转至

Generate Object Explorer URLs(生成 Object Explorer URL)

In the course of developing object views, or when integrating object views into Slate applications or external systems, you may need to generate URLs that link to a specific object or search for objects.

To learn about how to create a URL linking to a specific Object View, see Generating Object Views URLs in the Object Views documentation.

If your text contains special character or spaces, you will need to encode it:

encodeURIComponent("hello world");

Create a URL:

<BASEURL>/hubble/external/keyword/v0/<MY_ENCODED_TEXT>

Linking to explorations

Object Explorer can open links to specific object types, saved explorations, or new searches with filters described in the URL. Each type of link can be opened in the default Explore view, with charts showing aggregate results, or in the tabular Results view by appending the parameter perspectiveId=results to the end of the link URL.

Opening an object type For exploration

Explorations for specific object types can be opened with the objectTypeId URL parameter. For example:

/workspace/hubble/exploration?objectTypeId=aircraft.

To open in the Results view, append the perspectiveId=results parameter:

/workspace/hubble/exploration?objectTypeId=aircraft&perspectiveId=results

Loading a Saved Exploration or Object Set

Use the saved route to open a saved exploration or object set.

/workspace/hubble/exploration/saved/ri.object-set.main.versioned-object-set.4b117663-06d7-4bd1-a2be-8e1ba20998cb

To load an object set created by another Foundry application, use the external/objectSet route.

/workspace/hubble/external/objectSet/v0/ri.object-set.main.object-set.f6916120-5b52-4312-8be4-9f5764983907

Generate your set of filters to look like:

{
  "keyword": "",
  "objectTypes": [
    "google-reviews"
  ],
  "filters": [
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "Description",
      "value": {
          "type": "textFilter",
          "text": "hello"
      }
    },
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "rating",
      "value": {
          "type": "valuesFilter",
          "values": ["3", "4"]
      }
    },
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "creation-date",
      "value": {
          "type": "dateRangeFilter",
          "dateRangeFilter": {
              "start": "2000-01-10",
              "end": "2000-01-11"
          }
      }
    },
    {
      "type": "linkFilter",
      "objectType": "google-reviews",
      "linkType": "restaurant-to-review",
      "value": {
          "type": "presenceFilter",
          "matchType": "MUST_HAVE"
      }
    }
  ]
}

There are more types of filters available, including:

  • numberRangeFilter: min (optional number), max (optional number)
  • relativeDateFilter: sinceDaysAgo (optional number), untilDaysAgo (optional number)
  • timestampRangeFilter: startMillis (optional number), endMillis (optional number)
  • relativeTimestampFilter: sinceMillisAgo (optional number), untilMillisAgo (optional number)

:::callout{theme="neutral"} This example may be out of date – use the instructions below to find out the latest format. :::

The type of the value must match the type of widget that shows by default for that property in Object Explorer. For example: valuesFilter for a histogram widget; textFilter for textbox.

The recommended way to generate these filters is:

  1. Open Object Explorer and build an example search, with sample values chosen for all the filters you wish to generate

  2. Open the Chrome Console (right click -> inspect element). Make sure you inspect an element that Object Explorer provides, such as the resulting count, rather than just opening the Chrome Console.

  3. Run await hubble_get_current_search() in the console.

This will return the JSON for your current set of filters, which you can use to work out the correct format, and add substitutions for the values.

:::callout{theme="neutral"} You can have many PROPERTY filters, but only 1 LINK filter. :::

  1. URL encode it:

encodeURIComponent(<MY_FILTERS>);

  1. Create a URL:

<BASEURL>/hubble/external/search/v2/{<ENCODED-URL-FROM-ABOVE>}


中文翻译


生成 Object Explorer URL

在开发对象视图(Object Views)或将其集成到 Slate 应用或外部系统时,您可能需要生成指向特定对象或搜索对象的 URL。

关于如何创建指向特定对象视图的 URL,请参阅对象视图文档中的生成对象视图 URL

生成仅含关键词的搜索

如果文本包含特殊字符或空格,您需要对其进行编码:

encodeURIComponent("hello world");

创建 URL:

<BASEURL>/hubble/external/keyword/v0/<编码后的文本>

链接到探索(Explorations)

Object Explorer 可以打开指向特定对象类型、已保存探索或 URL 中描述的新搜索(带筛选条件)的链接。每种类型的链接都可以在默认的探索视图中打开(显示聚合结果的图表),也可以通过向链接 URL 末尾添加参数 perspectiveId=results 在表格结果视图中打开。

打开对象类型进行探索

可以通过 objectTypeId URL 参数打开特定对象类型的探索。例如:

/workspace/hubble/exploration?objectTypeId=aircraft

要在结果视图中打开,请附加 perspectiveId=results 参数:

/workspace/hubble/exploration?objectTypeId=aircraft&perspectiveId=results

加载已保存的探索或对象集(Object Set)

使用 saved 路由打开已保存的探索或对象集。

/workspace/hubble/exploration/saved/ri.object-set.main.versioned-object-set.4b117663-06d7-4bd1-a2be-8e1ba20998cb

要加载由其他 Foundry 应用创建的对象集,请使用 external/objectSet 路由。

/workspace/hubble/external/objectSet/v0/ri.object-set.main.object-set.f6916120-5b52-4312-8be4-9f5764983907

[高级] 生成复杂搜索

将筛选条件集合生成为如下格式:

{
  "keyword": "",
  "objectTypes": [
    "google-reviews"
  ],
  "filters": [
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "Description",
      "value": {
          "type": "textFilter",
          "text": "hello"
      }
    },
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "rating",
      "value": {
          "type": "valuesFilter",
          "values": ["3", "4"]
      }
    },
    {
      "type": "propertyFilter",
      "objectType": "google-reviews",
      "propertyType": "creation-date",
      "value": {
          "type": "dateRangeFilter",
          "dateRangeFilter": {
              "start": "2000-01-10",
              "end": "2000-01-11"
          }
      }
    },
    {
      "type": "linkFilter",
      "objectType": "google-reviews",
      "linkType": "restaurant-to-review",
      "value": {
          "type": "presenceFilter",
          "matchType": "MUST_HAVE"
      }
    }
  ]
}

还有其他可用的筛选条件类型,包括:

  • numberRangeFilter: min(可选数字)、max(可选数字)
  • relativeDateFilter: sinceDaysAgo(可选数字)、untilDaysAgo(可选数字)
  • timestampRangeFilter: startMillis(可选数字)、endMillis(可选数字)
  • relativeTimestampFilter: sinceMillisAgo(可选数字)、untilMillisAgo(可选数字)

:::callout{theme="neutral"} 此示例可能已过时——请使用以下说明查找最新格式。 :::

值的类型必须与 Object Explorer 中该属性默认显示的小部件类型匹配。例如:直方图小部件使用 valuesFilter;文本框使用 textFilter

生成这些筛选条件的推荐方法如下:

  1. 打开 Object Explorer 并构建一个示例搜索,为您希望生成的所有筛选条件选择示例值

  2. 打开 Chrome 控制台(右键单击 -> 检查元素)。请确保检查的是 Object Explorer 提供的元素(例如结果计数),而不仅仅是打开 Chrome 控制台。

  3. 在控制台中运行 await hubble_get_current_search()

这将返回当前筛选条件集合的 JSON,您可以用它来确定正确的格式,并对值进行替换。

:::callout{theme="neutral"} 您可以设置多个属性筛选条件,但只能设置 1 个链接筛选条件。 :::

  1. 对其进行 URL 编码:

encodeURIComponent(<我的筛选条件>);

  1. 创建 URL:

<BASEURL>/hubble/external/search/v2/{<上述编码后的URL>}