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

Reply via email to