Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search shows no results if more than one entry in mainSections #290

Closed
1 task
robe2 opened this issue Apr 26, 2022 · 8 comments
Closed
1 task

Search shows no results if more than one entry in mainSections #290

robe2 opened this issue Apr 26, 2022 · 8 comments

Comments

@robe2
Copy link

robe2 commented Apr 26, 2022

I have checked all the prerequisites below and I'm yet experiencing a problem

  • [ x] Read the README.md
  • [ x] Have the extended version of Hugo installed
  • [ x ] Used the exampleSite's config.toml as a reference
  • I have included my repository link. Instead of pasting long snippets here.

Describe the bug

Search does not find anything if more than one directory specified in mainSections.

I have 3 directories: post, pages, events

If I put any of the below in my params.toml file, then it can search just that section
mainSections = ["post"]

or
mainSections = ["events"]

or
mainSections = ["pages"]

However if I put all of them in like so:

mainSections = ["post", "events", "pages"]

Then search finds nothing.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome, Firefox
@rootwork
Copy link
Contributor

@onweru Can you take a look when you get a chance?

@timatlee
Copy link
Contributor

I don't know if this can be considered a related question, but I would be interested to understand how to get the passive search function to search multiple sections (ie, "post" and "recipe") without having to set "recipe" as a mainSection.

I think once I understand how multiple mainSections are searched, I could probably set a config for searchSections and submit a PR...

@onweru
Copy link
Collaborator

onweru commented May 14, 2022

@timatlee, at the moment, the search function should search the entire site. This may not be ideal. First I'll explore the anomaly described by @robe2.

As an improvement, I might introduce the concept of search scope. For granular search

@timatlee
Copy link
Contributor

@onweru I do see the content for the whole site being generated in index.json, but the passive search seems to be limited to content within the "posts" content type. At least, the experience that I'm seeing at the moment does not surface the content in the "recipe" type:
image

I should have annotated that image, but the URL path is showing that I'm in /recipe, but typing in a search query for a post that is clearly listed is not shown in the search results.

Limited screenshot showing that the post in question is in index.json:
image

If I change /layouts/partials/search/widget.html's data-scope to "recipe", I get the opposite behaviour - searching just the recipe's, but not the "post" content.

I'm not sure how I can illustrate this, to be honest.

The same behaviour exists using the exampleSite and the 'page' content types - the About page is in index.json, but does not surface in the search results, though in that case, the About page in index.json does not have a section value.

I understand that the search behaviour for the whole site may not be ideal. Once the initial anomaly is addressed, I thought I would take an attempt at a way to define the search scope within the site's configuration... but at the instant in time, I don't have a good understanding of how the search component works :)

Thanks for your response!

@onweru
Copy link
Collaborator

onweru commented May 14, 2022

@timatlee, thanks for this feedback. I will ready a fix asap.

@onweru
Copy link
Collaborator

onweru commented May 14, 2022

@timatlee, watch out for when #301 is merged. It will fix your issue.

@timatlee
Copy link
Contributor

@onweru Thanks! Great fix, and seems like it strikes a good balance of site-wide versus section-wide searching. Great work!

@onweru
Copy link
Collaborator

onweru commented May 19, 2022

Thanks, @timatlee. I will close this issue now. Keep an eye on #308 for further improvements on section-scoped search.

@onweru onweru closed this as completed May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants