How can I search chat history by keyword in real-time manner?

To search chat history by keyword in real-time using Sendbird, you can use the message search feature provided by the Sendbird Chat API. This feature allows you to retrieve a list of messages that contain a search term from a specific group channel. You can look for exact or partial matches to your search terms and filter search results using message properties like target_user_ids, message_ts_from, or message_ts_to. You can also use various advanced search functionalities to enhance your search results.

For example, let’s say you have a chat app where users can discuss different types of fruits. You want to allow users to search for messages that contain a specific fruit name, such as “apple” or “orange”. To do this, you can use the message search feature provided by Sendbird Chat API.

First, you would need to initialize and configure the chat with minimal effort using the Sendbird Chat SDK for JavaScript or iOS. Once the chat is set up, you can use the message search API endpoint to search for messages containing the search term.

For example, to search for messages containing the word “apple”, you can use the following API endpoint:

GET /search/messages?q=apple

This will return a list of messages that contain the word “apple” in the text. You can also use advanced search functionalities to enhance your search results, such as using logical operators to search for more than one term or specifying target fields to search for specific message properties.

For example, to search for messages containing the word “fruit” and either the word “apple” or “orange” in the text, you can use the following API endpoint:

GET /search/messages?q=fruit%20AND%20(apple%20OR%20orange)

This will return a list of messages that contain the word “fruit” and either the word “apple” or “orange” in the text.

Overall, the message search feature provided by Sendbird Chat API allows you to search chat history by keyword in a real-time manner, making it easy for users to find specific messages or topics of interest.

Please refer to the below documentation for more information: