…thinking further on this, can I return a number of fields with the index that aren’t searched? EG if I have a ‘doc.createdDate’, how can I just return that with the data?
> On 12 Nov 2023, at 18:19, TDAS <talldarkandstra...@icloud.com.INVALID> wrote: > > Basically, I was hoping that I could have the search query return the name of > the person linked to that document. Just to save doing further queries to > convert a list of IDs to users. > >> On 12 Nov 2023, at 17:24, Robert Newson <b...@rsn.io> wrote: >> >> chatgpt makes everything up. :) >> >> You can't fetch another document during the indexing callbacks. >> >> Perhaps explain what you're trying to achieve? >> >> \b. >> >>> On 11 Nov 2023, at 23:54, TDAS <talldarkandstra...@icloud.com.INVALID> >>> wrote: >>> >>> getDoc doesn’t exist? Did chatgpt just make that up?! Man… >>> >>> Is there an alternative? >>> >>>> On 11 Nov 2023, at 22:52, Robert Newson <rnew...@apache.org> wrote: >>>> >>>> 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 }); >>>>> // } >>>>> // } >>>>> } >>>>> } >>>> >>>> >>> >> >