Intelligent Search - Post
Introduction
The Intelligent Search Post API allows users to search for posts with advanced filtering options. The search includes all targets where the user has permission to view posts. However, you can refine the results using specific filters for target types, target IDs, post types, or parent-child relationships.
Target Filtering
By default, the search will include all targets where the user can view posts. However, you can narrow the search scope to a specific target by specifying both the targetType and targetId together.
targetType: Defines the type of target where the post was created, eithercommunityoruserfeed.targetId: The ID of the designated target, i.e, community id whentargetTypeiscommunity; user id whentargetTypeisuser.
Post Filtering
You can choose to filter specific post types or based on parent-child relationships.
matchingOnlyParentPostWhen set to
true, only parent posts are included, excluding child posts from the search.When set to
false, both parent and child posts are included in the search.
postTypes: Filters posts by type. Currently supports filtering fortextandimageposts.
Example Use Cases
Search for Text Posts
When the user searches for "ice cream," the output may include posts ranked by their relevance score. For example:
Text Post 1st: "I love ice cream."
Text Post 2nd: "Ice cream is my favorite dessert."
Text Post 3rd: "Nothing beats a scoop of ice cream on a hot day!"
Text Post 4th: "I enjoy trying different types of pastries."
Text Post 5th: "Cooking is a great way to relax after a long day."Search for Image Posts
When the user searches for "ice cream," the output may include posts ranked by their relevance score. For example:

image post — 1st
caption: I love ice cream.

image post — 2nd
caption: <no caption>

image post — 3rd
caption: food on my table!
The following code snippet demonstrates how to search for text and image posts across the entire network. Users can filter the results to display only text, images, or both, depending on their preference.
Limitations
Currently, the search only supports text and image posts; other post types are not included.
The search function only considers the context of individual posts. It does not consider the relationship between parent posts, their replies, or comments.
Last updated
Was this helpful?