Content Search V2 (Deprecated)

Content Search allows you to perform more complex content searching and sorting. The feature can be used for the following use cases:

  • Search post by text content

  • Find posts that contain a specific hashtag

  • Sort post by last activity or reaction count

Search Posts

Search Posts API can be used to search and sort relevant posts created into social.plus. All APIs will return sorted list of post IDs that contains relevant contents.

API Reference

(V2) Search posts by query as indicated in request JSON body

POST https://beta.amity.services/search/v2/posts

Headers

Name
Type
Description

Authorization*

String

Bearer {accessToken}

(accessToken is retrieved from Amity SDK)

Request Body

Name
Type
Description

query*

JSON

Query JSON (see below)

sort

JSON

Sort JSON (see below)

from

Number

Offset from the first result to be fetched

size

Number

Maximum amount of IDs to be returned

populatePostObject

Bool

Include post object in response or not?

(V2) Search posts by query as indicated in request JSON body

POST https://beta.amity.services/search/v2/posts

Headers

Name
Type
Description

Authorization*

String

4GhW4Zkn5wyA

Request Body

Name
Type
Description

query*

JSON

ksvJag3FnmK7

sort

JSON

DPUspUSAMciZ

from

Number

PQwGuNG9QW0L

size

Number

HPqjW34NqGXA

populatePostObject

Bool

2qk6tMD7d9su

When populatePostObject is set to true, the posts object will be retrieved from the API separately and will not be cached within the SDK. If the user wants to subscribe to the post object and use LiveObject/LiveCollection, they should use getList from the SDK.

Query JSON

query is a JSON object that indicates the posts to be searched for. The following is the full JSON structure with all the fields:

All fields are optional. If targetId is present the system will search for posts on those communities. If targetId is not specified the system will search for all posts created by userId calling the API.

For Search V2:

targetType can be the following values:

  • community - search posts in all communities ID as defined in targetId

  • self - search all posts that belongs to the user passed in userId within request body

  • public - search all posts that is in all public communities

Limitations

Current limitations on Search Posts API are

  • Posts created on user feed is not yet searchable.

Query & Sort Format

NumberQuery

NumberQuery JSON structure defines range of numerical value to look for in a property. Available fields within the JSON structure are:

TimeQuery

TimeQuery JSON structure defines range of date time value to look for in a property. Available fields within the JSON structure are:

Time string in TimeQuery must be in ISO Date Format: YYYY-MM-DDThh:mm:ss.sZ

Sort JSON

sort is a JSON array that indicates how should the returning contents be sorted. The following is the full JSON structure:

The returning content IDs will be sorted by the sort priority defined in Sort JSON. sort_field is the field the post should be sorted by - this can be any of the field Query JSON that is in NumberQuery or TimeQuery format.

  • We currently do not support searching within a post’s metadata.

Last updated

Was this helpful?