chatpal / chatpal-search-standalone

Standalone Server for Chatpal-Search
15 stars 6 forks source link

How the querying works #2

Open kb0304 opened 6 years ago

kb0304 commented 6 years ago

I tried to replicate via postman the request that rocket chat instance makes to fetch messages. But it's not working as I am expecting it to be. Can I please get some insight into how the querying part works.

So, I put a log statement here. `query(params, callback) {

            const options = {
                    params,
                    ...this._options.httpOptions
            };

            ChatpalLogger.debug('query: ', JSON.stringify(options, null, 2));

            try {
                    console.log(this._options.baseurl + this._options.searchpath)
                    console.log(options);
                    if (callback) {
                            HTTP.call('POST', this._options.baseurl + this._options.searchpath, options, (err, result) => {
                                    if (err) { return callback(err); }

                                    console.log(result)
                                    callback(undefined, result.data);
                            });`

And got the following output.

http://localhost:8983/solr/chatpal/chatpal/search { params: { text: 'hello', language: 'en', acl: [ 'GENERAL', '95fMZdLBTwQWjK9r8', 'rocket.catxfdFdNMkTRgyCgJWD' ], type: [ 'message', 'user', 'room' ], start: 0, rows: 15 }, headers: {} }

Then I tried to replicate the same in postman, like postman

But it gives me a 400 error, ` "msg": "Unknown top-level key in JSON request : text"

Also, interestingly the following works, but it only returns users, here i have checked the rows limit postman2

The documents exists in the solr, everything works fine when you search via Rocket Chat UI.

@tkurz @mrsimpson

mrsimpson commented 6 years ago

@tkurz @westei I checked the solr configuration and noticed that the index holds fields text_<languageKey>, while the API seems to operate on {text: <...>, language: <languageKey>}. For a Solr-noob: may you help me where this transformation is implemented?

kb0304 commented 6 years ago

Also, by settings parameter user in params while querying doesn't seem to filter result based on the user while it works in Solr Admin. As @mrsimpson mentioned there seems to be a wrapper that parses the request to Solr query. Can someone please help out, how it works?

@rodrigok @hudell looping you in.

tkurz commented 6 years ago

Hi @kb0304 The query is not send via json but as form-url-encoded, which has a different syntax. Try this! @mrsimpson the transformation is implemented in the Solr Handlers (which are bundled in the Docker but not yet released as OS (which will happen in the next weeks)).

kb0304 commented 6 years ago

@tkurz Sure, i’ll try that. Also, I am not able to filter results by user by passing ‘user’ in params. Is anything to be done on solr side to implement the same?

ja-fra commented 6 years ago

Please have a look at chatpal-search-solr-ext to see the extensions we did to Solr.