Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global search can not get the search result #61

Open
tommychen1228 opened this issue Dec 11, 2020 · 9 comments
Open

Global search can not get the search result #61

tommychen1228 opened this issue Dec 11, 2020 · 9 comments
Assignees

Comments

@tommychen1228
Copy link

I used ConnectyCube.chat.search({search_text:keyword, limit:100}), but no result returned.
We have used 1 to 1 chat, can retrieve the dialogs and chat history.
So, whether if i used in a incorrect way?

@ccvlad
Copy link
Contributor

ccvlad commented Dec 21, 2020

Hi, @tommychen1228

Could you show logs with response - request. I have checked and I was able to get a result.

@tommychen1228
Copy link
Author

[Response][3] {"items": [{"_id": "5fd4b060ca8bf4155f08ca0b", "admins_ids": [Array], "created_at": "2020-12-12T11:58:24Z", "description": null, "last_message": "Asdfasdf", "last_message_date_sent": 1608565705, "last_message_id": "5fe0c3c93cb6ad2afc000002", "last_message_user_id": 2985729, "name": "花姐家 杜杜塞", "occupants_ids": [Array], "photo": null, "pinned_messages_ids": [Array], "type": 3, "unread_messages_count": 0, "updated_at": "2020-12-21T15:48:25Z", "user_id": 2985729, "xmpp_room_jid": null}, {"_id": "5fd6f5d14dad4dad0ae53936", "admins_ids": [Array], "created_at": "2020-12-14T05:19:13Z", "description": null, "last_message": "Voice", "last_message_date_sent": 1608358223, "last_message_id": "5fdd994f64b8c230f9000007", "last_message_user_id": 2985728, "name": "patient two 1007", "occupants_ids": [Array], "photo": null, "pinned_messages_ids": [Array], "type": 3, "unread_messages_count": 0, "updated_at": "2020-12-19T06:10:23Z", "user_id": 2999893, "xmpp_room_jid": null}, {"_id": "5fdca9e7ca8bf469299729a3", "admins_ids": [Array], "created_at": "2020-12-18T13:08:55Z", "description": null, "last_message": "Fhngbrge", "last_message_date_sent": 1608297135, "last_message_id": "5fdcaa9d6492ca1edd00000a", "last_message_user_id": 3002366, "name": "Qiu Hi", "occupants_ids": [Array], "photo": null, "pinned_messages_ids": [Array], "type": 3, "unread_messages_count": 0, "updated_at": "2020-12-18T13:12:15Z", "user_id": 3002366, "xmpp_room_jid": null}, {"_id": "5fd8c137ca8bf47469086d38", "admins_ids": [Array], "created_at": "2020-12-15T13:59:19Z", "description": null, "last_message": "Image", "last_message_date_sent": 1608296725, "last_message_id": "5fdca915a2c86a7285000000", "last_message_user_id": 2985728, "name": "123 123 123", "occupants_ids": [Array], "photo": null, "pinned_messages_ids": [Array], "type": 3, "unread_messages_count": 0, "updated_at": "2020-12-18T13:05:29Z", "user_id": 3007538, "xmpp_room_jid": null}, {"_id": "5fd6f5caca8bf4326f07cb12", "admins_ids": [Array], "created_at": "2020-12-14T05:19:06Z", "description": null, "last_message": null, "last_message_date_sent": null, "last_message_id": null, "last_message_user_id": null, "name": "Patient One 11", "occupants_ids": [Array], "photo": null, "pinned_messages_ids": [Array], "type": 3, "unread_messages_count": 0, "updated_at": "2020-12-14T05:19:06Z", "user_id": 2985789, "xmpp_room_jid": null}], "limit": 100, "skip": 0, "total_entries": 5}

This is the dialogs response, we can see that it contains a message "Asdfasdf", and then we search keyword "Asdf", the request and response is below:

[Request][4] GET https://api.connectycube.com/chat/search.json {"data": {"limit": 100, "search_text": "Asdf"}, "type": "GET", "url": "https://api.connectycube.com/chat/search.json"}
[Response][4] {"dialogs": [], "messages": [], "users": []}

@DaveLomber
Copy link
Contributor

@tommychen1228 so it searches for 'exact' match instead of 'contain', right?

@tommychen1228
Copy link
Author

No, no matter whether I use the full text or part of the text to search, no results are returned. Such as:
[Request][6] GET https://api.connectycube.com/chat/search.json {"data": {"limit": 100, "search_text": "12345"}, "type": "GET", "url": "https://api.connectycube.com/chat/search.json"}
[Response][6] {"dialogs": [], "messages": [], "users": []}

@tommychen1228
Copy link
Author

@DaveLomber Is the method I used incorrect?

@DaveLomber
Copy link
Contributor

Hi @tommychen1228

We prepared a simple script which does the following:

  • create session with user
  • create dialog
  • create message
  • the searches
const ConnectyCube = require("connectycube");

const CREDENTIALS = {
  appId: 000,
  authKey: "...",
  authSecret: "...",
};

const USER_ONE = {
  id: 000,
  login: "...",
  password: "..."
}

const USER_TWO = {
  id:  000,
  login: "...",
  password: "..."
}


ConnectyCube.init(CREDENTIALS, { debug: { mode: 1 }});


ConnectyCube.createSession(USER_ONE)
  .then(session => {

    ConnectyCube.chat.dialog
      .create({type: 2, name: "super dialog", occupants_ids: [USER_TWO.id]})
      .then((dialog) => {

        ConnectyCube.chat.message
          .create({chat_dialog_id: dialog._id, message: "This is my message"})
          .then((message) => {

            const params = {
              // search_text: "dial",
              search_text: "mess",
            };
            ConnectyCube.chat
              .search(params)
              .then((result) => {})
              .catch((error) => {});

          })
          .catch((error) => {});


      })
      .catch((error) => {});

  }).catch((error) => {});

then run it via node index.js

According to our tests, it successfully returns dialogs if search by search_text: "dial" and messages if search by search_text: "mess"

Could you please try it at your end and let us know

@tommychen1228
Copy link
Author

tommychen1228 commented Feb 16, 2021

@DaveLomber thank you for your reply.As your code, it works well. But I think I found the key point, the dialog created in my app, the type is 3 (1-1 chat), in your code the type is 2. if I change the dialog type to 3 and search, it returned nothing.So, whether the dialog with type 3 does not support search?

@DaveLomber
Copy link
Contributor

@tommychen1228 thanks for sharing more details

For 1-1 chat, we display other user's full_name/login as a chat dialog's name

You mean it does not search against other user's full_name/login ?

@banshiAnton banshiAnton self-assigned this Feb 17, 2021
@tommychen1228
Copy link
Author

@DaveLomber not only the 1-1 chat dialog's name, but also the messages in dialog, can‘t be searched. It seems like 1-1 chat is note supported search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants