Closed SukkaW closed 4 years ago
I think what @SukkaW is saying can be achieved by fields feature, however @olivernn can suggest better
How should I build my index to achieve this?
I think you've already built you search index in the correct way to do this. If, when searching, you only want to search specific fields, you can specify those when calling either search
or query
I want res.search('foo') only search through field title & content
You will have to specify the fields you want to search unless you want to search all of them. Using your example, and the search
method this would become:
res.search("title:foo content:foo")
I'm building a search engine for a JAMStack website using
lunr.js
and here is the case:As code shows above, I add 3 fields,
title
,content
andtags
. However, I want fieldtags
only be searched when specified. I mean:res.search('foo')
only search through fieldtitle
&content
res.search('tags:foo bar')
should search in the fieldtags
.How should I build my index to achieve this?