tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

How to Global Search? #2616

Closed CMfengbuzhi closed 11 months ago

CMfengbuzhi commented 1 year ago

Like the search on the Telegram homepage, global search can be performed.Which API interface should I use?

levlam commented 1 year ago

The search on the chat page is searchRecentlyFoundChats + searchChats + searchChatsOnServer + searchContacts + searchPublicChats + searchMessages + searchSecretMessages.

CMfengbuzhi commented 1 year ago

聊天页面上的搜索是searchRecentlyFoundChats + searchChats + searchChatsOnServer + searchPublicChats + searchMessages + searchSecretMessages.

Thank u. The searchChatsOnServer interface only returns data once when searching for the same content. Do developers need to save the returned data in the database themselves to avoid duplicate searches? Is there another interface for querying tdlib's saved search results?

levlam commented 1 year ago

You don't need database. You must add results from the mentioned request in the specified order. skipping previously received chats, users and messages.

CMfengbuzhi commented 1 year ago

You don't need database. You must add results from the mentioned request in the specified order. skipping previously received chats, users and messages.

Why sometimes using searchChatsOnServer to search does not return data, while using tg to search results in data? Is this a problem with the limit parameter? How should limit be written?

levlam commented 1 year ago
//@description Searches for the specified query in the title and username of already known chats via request to the server. Returns chats in the order seen in the main chat list @query Query to search for @limit The maximum number of chats to be returned
searchChatsOnServer query:string limit:int32 = Chats;

The method works as documented. It can return only chats from the chat list.