Overview
Discover users in your community through powerful search and query capabilities. social.plus SDK provides methods to search users by display name and retrieve user collections with various sorting options.Deleted users are automatically excluded from all search and query results to maintain data integrity.
Search vs Query
Search Users
Find users by display name with keyword matching
Query Users
Retrieve user collections with sorting options
Search User
Query for users by their display name, receiving a collection of AmityUser matching your search. It requires two parameters: the display name you’re searching for, and a ‘sort option’ from the AmityUserSortOption enum.Search Requirements
- Search keywords must be at least 3 characters long
- If no keyword is supplied, the list of users will be organized alphabetically by display name
- When a keyword is provided, the list will be arranged based on search rank
- The displayName sorting option will be specified by default if it isn’t specified
Sorting Options
Users have the option to sort by:- displayName: Alphabetical sorting using ICU collation for English locale (default)
- lastCreated: Most recently created users first
- firstCreated: Oldest users first
Special Character Handling
With the displayName sorting option, users are sorted alphabetically by their display names using ICU collation for the English locale. This means that special characters such as Ä are treated as variants of A. For example, a sorted list might appear as: adam, Älex, Alice, Arthur, charlie, Kristen.When providing a search keyword, the API performs an exact-match lookup for special characters:
- Searching for “Äli” will only return users whose display name contains “Äli” (e.g., “Älise”)
- Searching for “Alice” will NOT return “Älice”
Search Implementation
Query Users
Query for users to receive a collection of AmityUser based on a single parameter: a ‘sort option’ from the AmityUserSortOption enum. Sort the list by options such as displayName, firstCreated, or lastCreated. The displayName sort option will be specified by default if it isn’t specified.Sorting Behavior
With the displayName sorting option, users are sorted alphabetically by their display names using ICU collation for the English locale. This means that special characters such as Ä are treated as variants of A. For example, a sorted list might appear as: adam, Älex, Alice, Arthur, charlie, Kristen.Deleted users are excluded from the results
Query Implementation
Best Practices
Search Performance
Search Performance
- Implement debouncing for real-time search to reduce API calls
- Use minimum character requirements (3+) before triggering search
- Cache search results for better user experience
- Show loading states during search operations
Result Handling
Result Handling
- Implement pagination for large result sets
- Handle empty search results gracefully
- Provide clear feedback for search criteria that return no results
- Show user count and result statistics when helpful
User Experience
User Experience
- Sort results by relevance when using search keywords
- Highlight matching text in search results
- Provide filters for different user types or statuses
- Enable sorting options based on user needs