Hi,

The problem is that getDoc() function doesn't exist, and so the evaluation of 
this throws an error, which causes the document not to be indexed at all.

B.

> On 11 Nov 2023, at 17:30, TDAS <talldarkandstra...@icloud.com.INVALID> wrote:
> 
> Hey all
> 
> I have Clouseau running, and have written a search index which is working 
> nicely.
> 
> However when I try to link a document, the search stops returning any results.
> 
> I’ve checked it with chatgpt (so it must be right, hey!) :)
> 
> Can anyone point out what I’m doing wrong?
> 
> 
> The doc.owner is the ID of the user document, and the commented out section 
> is the lookup I’m trying (that breaks the search). I’ve tried indexing it 
> under ‘default’ to see if that was it, and also tried using a different index 
> name, like ‘user’.
> 
> function (doc) {
>   if(!doc.deleted && doc.type) {
>    index('type', doc.type, {"store":true})
> 
>    if (doc.type === 'user' && doc.firstname && doc.lastname) {
>    index('default', doc.firstname + ' ' + doc.lastname, {"store": true});
>    }
>    if(doc.addresses) {
>      for(const address of doc.addresses) {
>        if(address.postcode)
>        index('default', address.postcode, {"store": true})
>        index('default', address.main.replace(/\n/g, ', '), {"store": true})
>      }
>    }
>    if(doc.email) {
>      index('default', doc.email, {"store": true})
>    }
>    if(doc.c_provider) {
>      index('default', doc.c_provider, {"store": true})
>    }
>    if(doc.c_policy_number) {
>      index('default', doc.c_policy_number, {"store": true})
>    }
> 
>    // if (doc.owner) {
>    //   var userDoc = getDoc(doc.owner);
>    //   if (userDoc && userDoc.firstname && userDoc.lastname) {
>    //       index('owner', userDoc.firstname + ' ' + userDoc.lastname, { 
> "store": true });
>    //   }
>    // }
>  }
> }


Reply via email to