You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Rick Jarvis <ri...@magicmail.mooo.com> on 2022/05/09 16:40:17 UTC

Issue with search

Apologies if this is a duplicate, I think I might have used the wrong email address:

I’ve migrated couchdb over to a new server, using replication. Latest couchdb running on Debian 11.

Everything is working except ‘find’ (using Nano, from a NodeJs app).

It’s a long time since I set the search tree up, but essentially it looks like the below (if of interest) - I can’t really remember how it works!

Is there anything I need to do since moving to the new server to make it work? I can’t see any obvious errors in the couchdb logs. Client times out, and I get this in the node logs (I think this is coming from the error, but it’s production, so difficult to pinpoint atm):

0|main  | Error: error happened in your connection
0|main  |     at responseHandler (/var/app/node_modules/nano/lib/nano.js:120:16)
0|main  |     at axios.then.catch (/var/app/node_modules/nano/lib/nano.js:405:13)
0|main  |     at process._tickCallback (internal/process/next_tick.js:68:7)

var subquery = {      // q is search term
       selector: {
           $and: [
               {
                   $or: [{ type: { $eq: 'case' } }, { type: { $eq: 'user' } }, { type: { $eq: 'property' } }],
               },
               {
                   $or: [
                       { email: { $regex: q } },
                       { firstname: { $regex: q } },
                       { lastname: { $regex: q } },
                       { p_forenames: { $regex: q } },
                       { p_surname: { $regex: q } },
                       { p_forenames2: { $regex: q } },
                       { p_surname2: { $regex: q } },
                       { n_company_name: { $regex: q } },
                       { n_property_address: { $regex: q } },
                       { n_property_address_postcode: { $regex: q } },
                       { c_provider: { $regex: q } },
                       { c_policy_number: { $regex: q } },
                       { c_product_code: { $regex: q } },
                   ],
               },
           ],
       },
       fields: [
           'type',
           '_id',
           'firstname',
           'lastname',
           'p_forenames',
           'p_surname',
           'p_forenames2',
           'p_surname2',
           'email',
           'role',
           'clientid',
           'adviser',
           'p_joint',
           'n_property_address',
           'n_property_address_postcode',
           'c_provider',
           'c_policy_number',
           'c_product_code',
           'mb_deleted',
           'n_company_name',
           'created',
       ],
       limit: 50,
   };

   couch.find(subquery, function(err, data) { ... })

-- 
Rick Jarvis

Re: Issue with search

Posted by Robert Newson <rn...@apache.org>.
Hi Rick,

I think the explanation is straight-forward given your last comment. Indexes are not replicated, they are only built locally. So that original error is likely a timeout waiting for the index to build.

B.

> On 9 May 2022, at 21:16, Rick Jarvis <ri...@magicmail.mooo.com> wrote:
> 
> It would appear it is actually speed. For some reason, search is a lot slower on a rebuilt vm with the same specs.
> 
> Is there any control over indexing / verifying it’s happening ok? I’m not at all sure how the search functionality works if I’m hones...
> 
> -- 
> Rick Jarvis
> 
> On 9 May 2022 at 17:40:23, Rick Jarvis (rick@magicmail.mooo.com) wrote:
> 
> Apologies if this is a duplicate, I think I might have used the wrong email address:
> 
> I’ve migrated couchdb over to a new server, using replication. Latest couchdb running on Debian 11.
> 
> Everything is working except ‘find’ (using Nano, from a NodeJs app).
> 
> It’s a long time since I set the search tree up, but essentially it looks like the below (if of interest) - I can’t really remember how it works!
> 
> Is there anything I need to do since moving to the new server to make it work? I can’t see any obvious errors in the couchdb logs. Client times out, and I get this in the node logs (I think this is coming from the error, but it’s production, so difficult to pinpoint atm):
> 
> 0|main  | Error: error happened in your connection
> 0|main  |     at responseHandler (/var/app/node_modules/nano/lib/nano.js:120:16)
> 0|main  |     at axios.then.catch (/var/app/node_modules/nano/lib/nano.js:405:13)
> 0|main  |     at process._tickCallback (internal/process/next_tick.js:68:7)
> 
> var subquery = {      // q is search term
>        selector: {
>            $and: [
>                {
>                    $or: [{ type: { $eq: 'case' } }, { type: { $eq: 'user' } }, { type: { $eq: 'property' } }],
>                },
>                {
>                    $or: [
>                        { email: { $regex: q } },
>                        { firstname: { $regex: q } },
>                        { lastname: { $regex: q } },
>                        { p_forenames: { $regex: q } },
>                        { p_surname: { $regex: q } },
>                        { p_forenames2: { $regex: q } },
>                        { p_surname2: { $regex: q } },
>                        { n_company_name: { $regex: q } },
>                        { n_property_address: { $regex: q } },
>                        { n_property_address_postcode: { $regex: q } },
>                        { c_provider: { $regex: q } },
>                        { c_policy_number: { $regex: q } },
>                        { c_product_code: { $regex: q } },
>                    ],
>                },
>            ],
>        },
>        fields: [
>            'type',
>            '_id',
>            'firstname',
>            'lastname',
>            'p_forenames',
>            'p_surname',
>            'p_forenames2',
>            'p_surname2',
>            'email',
>            'role',
>            'clientid',
>            'adviser',
>            'p_joint',
>            'n_property_address',
>            'n_property_address_postcode',
>            'c_provider',
>            'c_policy_number',
>            'c_product_code',
>            'mb_deleted',
>            'n_company_name',
>            'created',
>        ],
>        limit: 50,
>    };
> 
>    couch.find(subquery, function(err, data) { ... })
> 
> -- 
> Rick Jarvis


Re: Issue with search

Posted by Rick Jarvis <ri...@magicmail.mooo.com>.
It would appear it is actually speed. For some reason, search is a lot slower on a rebuilt vm with the same specs.

Is there any control over indexing / verifying it’s happening ok? I’m not at all sure how the search functionality works if I’m hones...

-- 
Rick Jarvis

On 9 May 2022 at 17:40:23, Rick Jarvis (rick@magicmail.mooo.com) wrote:

Apologies if this is a duplicate, I think I might have used the wrong email address:

I’ve migrated couchdb over to a new server, using replication. Latest couchdb running on Debian 11.

Everything is working except ‘find’ (using Nano, from a NodeJs app).

It’s a long time since I set the search tree up, but essentially it looks like the below (if of interest) - I can’t really remember how it works!

Is there anything I need to do since moving to the new server to make it work? I can’t see any obvious errors in the couchdb logs. Client times out, and I get this in the node logs (I think this is coming from the error, but it’s production, so difficult to pinpoint atm):

0|main  | Error: error happened in your connection
0|main  |     at responseHandler (/var/app/node_modules/nano/lib/nano.js:120:16)
0|main  |     at axios.then.catch (/var/app/node_modules/nano/lib/nano.js:405:13)
0|main  |     at process._tickCallback (internal/process/next_tick.js:68:7)

var subquery = {      // q is search term
       selector: {
           $and: [
               {
                   $or: [{ type: { $eq: 'case' } }, { type: { $eq: 'user' } }, { type: { $eq: 'property' } }],
               },
               {
                   $or: [
                       { email: { $regex: q } },
                       { firstname: { $regex: q } },
                       { lastname: { $regex: q } },
                       { p_forenames: { $regex: q } },
                       { p_surname: { $regex: q } },
                       { p_forenames2: { $regex: q } },
                       { p_surname2: { $regex: q } },
                       { n_company_name: { $regex: q } },
                       { n_property_address: { $regex: q } },
                       { n_property_address_postcode: { $regex: q } },
                       { c_provider: { $regex: q } },
                       { c_policy_number: { $regex: q } },
                       { c_product_code: { $regex: q } },
                   ],
               },
           ],
       },
       fields: [
           'type',
           '_id',
           'firstname',
           'lastname',
           'p_forenames',
           'p_surname',
           'p_forenames2',
           'p_surname2',
           'email',
           'role',
           'clientid',
           'adviser',
           'p_joint',
           'n_property_address',
           'n_property_address_postcode',
           'c_provider',
           'c_policy_number',
           'c_product_code',
           'mb_deleted',
           'n_company_name',
           'created',
       ],
       limit: 50,
   };

   couch.find(subquery, function(err, data) { ... })

-- 
Rick Jarvis