<p>I've also seen this issue myself when using weightedsearch and as a result I have jsut gone and created a solution for this by adding a new parameter to the substringSearch function.</p>

<p>I've also commented on the issue which was raised back in January on the weightedsearch github page and added my updated files as a zip file, so please feel free to download it and give it a go if you wish. By putting it onto the issue tracker they will hopefully pull this feature into the plugin in a future release now.</p>

<p>You can see further details here: <a href="https://github.com/wja-no/craft-weighted-search/issues/1" rel="nofollow noreferrer">https://github.com/wja-no/craft-weighted-search/issues/1</a> </p>

CC BY-SA 3.0
2016-12-07T10:50:18.123Z
2016-12-07T10:50:18.123Z
Matt Shearing
<p>Without having used the plugin - have you tried something like:</p>

<pre><code>{% set params = { section: 'mysection' } %}
</code></pre>

CC BY-SA 3.0
2016-12-07T11:10:43.483Z
Thanks Nutmeg. Unfortunately there was a fair amount of changes which needed to be made to the plugin, which you can see from Matt's answer - who has also kindly submitted the code updates to the plugin developer, so hopefully these will get integrated into the plugin in the near future. Thank you.
Laura Montgomery
CC BY-SA 3.0
2016-12-05T19:54:37.940Z
2016-12-05T19:54:37.940Z
Nutmeg
<p>I'm using <a href="https://github.com/wja-no/craft-weighted-search" rel="nofollow noreferrer">Weighted Search</a> on a site and want to prevent the results from listing entries from certain sections.</p>

<p>Looking at the README.md suggests that this functionality has not been built into the plugin. However, does anyone have any experience of getting the plugin to only search in certain sections? Either through the <code>{% set results %}</code> OR tweaking the plugin?</p>

<p>I've tried added <code>.section('mysection')</code> to the <code>{% set results %}</code> but this seems to break the search.</p>

<pre><code>// Working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query) %}

// Not working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query).section('mysection') %}
</code></pre>

<p>Hoping someone else has managed this and I don't have to go back to the standard Craft search.</p>

<p>Thanks</p>

<search>
Limit by section in Weighted Search
# Limit by section in Weighted Search

(Asked by: username_0 on 2016-12-05)

I'm using Weighted Search on a site and want to prevent the results from listing entries from certain sections.
Looking at the README.md suggests that this functionality has not been built into the plugin. However, does anyone have any experience of getting the plugin to only search in certain sections? Either through the {% set results %} OR tweaking the plugin?
I've tried added .section('mysection') to the {% set results %} but this seems to break the search.
// Working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query) %}

// Not working

{% set query = craft.request.getParam('q') %}
{% set results = craft.weightedSearch.substringSearch(query).section('mysection') %}

Hoping someone else has managed this and I don't have to go back to the standard Craft search.
Thanks

**Tags:** search


---

## 2 answers

### Answer by username_1 on 2016-12-07. Score: 1 | Accepted answer

I've also seen this issue myself when using weightedsearch and as a result I have jsut gone and created a solution for this by adding a new parameter to the substringSearch function.

I've also commented on the issue which was raised back in January on the weightedsearch github page and added my updated files as a zip file, so please feel free to download it and give it a go if you wish. By putting it onto the issue tracker they will hopefully pull this feature into the plugin in a future release now.

You can see further details here: <https://github.com/wja-no/craft-weighted-search/issues/1>


---

### Answer by username_2 on 2016-12-05. Score: 0

Without having used the plugin - have you tried something like:
{% set params = { section: 'mysection' } %}

> **Comments:**
> **username_0**: Thanks username_2. Unfortunately there was a fair amount of changes which needed to be made to the plugin, which you can see from Matt's answer - who has also kindly submitted the code updates to the plugin developer, so hopefully these will get integrated into the plugin in the near future. Thank you.  

---

