Search function in certain categories

I wanted to know if there is a parameter in the search function. This parameter would allow searching only within specific categories. Yes, I know it can be done by typing the category name in the search bar, but I want to make things easier for my users.

Thank you.

You can do this using Advanced Header Search. Here’s a sample config:

Thanks for the info, but I don’t want to do an external search; I only want to search within Discourse, but in specific categories.

That’s exactlywhat i mean. You want to config it with the link for your category and add a “q?=” if i remember correctly. Here’s a sample link from meta: Search results for 'test #support:self-hosting' - Discourse Meta

You need to config it with your category icon.

Ah, okay, I didn’t get it :sweat_smile: the principle. Thanks for the info, so I’ll dive back into it. Thanks :+1:

when you are in the category to be searched, the search dropdown offers the in-cateogry option:

you could also teach them to use the /filter feature:

I just made a test, and if you set the “prefix” for “/search?context=category&context_id=YOUR_CATEGORY_ID_HERE&q=”, it’s works fine. here’s a preview, using the category id 8 and searching for “lara”:

Thanks for your help, I’m going to test it :+1:

I tested it, and thanks to @David_Ghost for the help, but I don’t find it intuitive to use. I’ll try to develop another approach. It’s worth noting that users always compare everything to other software, and it’s already complicated enough to get them to come or stay :sweat_smile:

But thank you for your help :+1:

Hi @gilles,

I have tested it, and I thank @David_Ghost for their assistance; however, I do not find its use intuitive.

I’m wondering if you could give a bit more detail about what you tried here, and what result you got. Perhaps you could share some screenshots?

Hello @Tris20,

I was looking for a search feature that searches two categories simultaneously on the forum while staying on the forum page. If I understood correctly, this results in two search bars with a logo for each search type. Users already find using Discourse complicated, so I’m trying to simplify the experience :rofl:. The issue these days is that users compare everything to everything. Maybe I’m using the component incorrectly.

What I wanted was to enter a search term and have the search engine look only within two configured categories.

The best option I see is

You can try this query on Meta:

Simple category:general,marketplace

Returns topics in the General and Marketplace categories with the word ‘simple’.

That is what the full page search does, make it easy for normal users to perform advanced searches with filters:

Can you explain to me how the advanced search helps users to search across multiple categories at the same time? I remember bringing up the issue when the wiki and documentation were split, but I don’t remember any changes since then.

Can you show to me where the OP asked about searching in specific categories at the same time?

From the translation, I understood that it is about being able to restrict search to specific categories, and that it was the same that is already possible via the search category operator, but in a more intuitive way

Maybe I lost something in translation :thinking:

At least the English translation says ‘simultaneously.’

I don’t want to create any problems; I know it’s not easy to find a perfect solution. Especially for me, the issue lies with users who aren’t necessarily used to forums, unlike chat platforms. I know there are default filters, and that doesn’t bother me at all since I’m accustomed to them, but I’m thinking of the beginner user. To make things even more complicated, they’re often in a hurry :sweat_smile:

I’m trying to find a solution for these users. My forum focuses on board games, and I have several categories covering all topics, except in two categories where I have game sheets.

I wanted to use the search bar only for game sheets.

Let’s say I have four categories: cat1, cat2, cat3, and cat4. My game sheets are located in cat2 and cat3.

When a user types “jeux1,” the search bar should, by default, search only within cat2 and cat3.

That’s my main challenge.

For me, this isn’t a problem since I’m familiar with the Discourse solution, but many users don’t want to complicate things. They want a quick, hassle-free solution.

For me, the biggest issue is simplifying the experience for users. I love Discourse; I find the community amazing, as well as the Discourse developers. I appreciate what you do, but Discourse needs to adapt to different usage scenarios. It’s not easy, and I understand that.

Would changing the search priority in the category settings work for you? That could make it way more likely for users to find topics from that category. You can experience that here on Meta by searching in support, which has a low priority so you find most topics from the subcategories like self-hosting.

Otherwise, I think you need a custom theme component to change the search experience for your users.

Thanks @Moin, I’ll give it a try :+1:

@Moin Awesome, I didn’t know about this feature. It works :+1: