Add search to two different sections using Lunr.js

Hi,
I have added a search bar for one of my section , Blogs. For that I am using this approach Janik Vonrotz - Simple Hugo page search with Lunr.js
I have added index.json file in my layouts folder.
It looks like this

[{{ range $index, $page := .Site.RegularPages }}
{{ if eq .Section "blogs" }}
{{- if ne $page.Type "json" -}}
{{- if and $index (gt $index 0) -}},{{- end }}
{
    "uri": "{{ $page.Permalink }}",
    "title": "{{ htmlEscape $page.Title}}",
    "content": {{$page.Plain | jsonify}}
}
{{- end -}}
{{- end -}}
{{- end -}}]

Now above is working fine , index.json file gets created in dist folder and search is working fine.
Now my next requirement is I want separate search but for a different section, Resource, so Blog’s search should search only in blogs and resource’s search in only resources folder.

For this I created another search.json file and placed it in layouts folder again with same as above code and only one line of code change i.e. {{ if eq .Section "resources" }}

But search.json file is not getting created in dist or anythwere for resources so the search does not work , but blogs still works.
What may be the issue ?
Config.toml has below code

[outputs]
home = [ “HTML”, “RSS”, “JSON”]

Need help.

put

section = [ "HTML", "JSON" ]

in your config

this should geneate a JSON in every section directory.

And remove

{{ if eq .Section "blogs" }} with the corrsponding {{ end }}

@ju52 Yes I tried this but still does not work.
My config looks like
[outputs]
home = [ “HTML”, “RSS”, “JSON”]
section = [“JSON”, “HTML”]

search.json file is in layouts folder with below code

[{{ range $index, $page := .Site.RegularPages }}
    {{- if ne $page.Type "json" -}}
    {{- if and $index (gt $index 0) -}},{{- end }}
    {
        "uri": "{{ $page.Permalink }}",
        "title": "{{ htmlEscape $page.Title}}",
        "content": {{$page.Plain | jsonify}}
    }
    {{- end -}}
    {{- end -}}]

No json file got created :frowning:
Is the location needs to be different for my search.json file ? Right now it is in layouts folder ,independent.

it’s hard to guess what happens, can you share a reository?

All “section” output files should be under this section.
Generate all files in public dir and look for it.

The mistake I made here was that the name of my json file which I placed in layouts folder , should be list.json and not search.json , it worked after rename. That’s weird.