Field expansion

There are a number of fields in the data available through the Meta Content Library API that are nested. For example, the statistics field contains the like_count, haha_count, and several other fields. When you create search objects, you might want to include some or all of the nested fields in your search. Field expansion allows you to perform queries for multiple fields and their nested fields in a single call. We refer to the nested fields as expanded fields.

In the Data dictionary, expanded fields are indicated by a dot notation. For example, statistics.like_count indicates that like_count is available within statistics. To specify expanded fields in your search objects, you can either use this dot notation or you can append the names of the expanded fields in curly braces after the parent field. See the examples in this section.

Specifying multiple fields

You can specify which multiple fields you want returned on any associated data by using the fields parameter, with the field names separated by commas.

# Return specific list of fields
response <- client$get(
      path="search/facebook_posts",
      params = list("q"="cybercrime", "fields"="id,text,lang")
)
# Return specific list of fields
response = client.get(
    path="search/facebook_posts",
    params={"q": "cybercrime", "fields": "id,text,lang"}
)
display(response.json()) # Display first page

Specifying expanded fields

You can specify which expanded fields you want returned on any associated data by using the dot notation in your query to specify first the parent field, then the expanded field (such as statistics.haha_count).

# Return specific list of fields
response <- client$get(
      path="search/facebook_posts",
      params = list("q"="cybercrime", "fields"="statistics.like_count,statistics.haha_count")
)
# Return specific list of fields
response = client.get(
    path="search/facebook_posts",
    params={"q": "cybercrime", "fields": "statistics.like_count,statistics.haha_count"}
)
display(response.json()) # Display first page

Alternatively, you can append a comma-separated list of expanded field names wrapped in curly braces to the end of any parent field name.

# Return specific list of fields
response <- client$get(
      path="search/facebook_posts",
      params = list("q"="cybercrime", "fields"="statistics{like_count,haha_count}")
)
# Return specific list of fields
response = client.get(
    path="search/facebook_posts",
    params={"q": "cybercrime", "fields": "statistics{like_count,haha_count}"}
)
display(response.json()) # Display first page

If you specify a field but do not specify any of its expanded fields, default expanded fields on the associated node are included in the response. If you omit the fields parameter altogether, default expanded fields on default parent fields on the associated data are included in the response.

Learn more