<p>I currently have the <a href="https://nystudio107.com/docs/similar" rel="nofollow noreferrer">Similar</a> plugin on my system, and I'm looking for similar entries by Category. It's working great, but I'm looking to limit the results to a specific section.</p>
<pre><code>    {% set limitCriteria = craft.entries().section('merchants').limit(4) %}
    {% set similarEntriesByCat = craft.similar.find({ element: entry, context: entry.vertical, criteria: limitCriteria }) %}

    &lt;ul&gt;
    {% for similarEntry in similarEntriesByCat %}
        &lt;li&gt;{{ similarEntry.title }} ({{ similarEntry.count }} tags in common)&lt;/li&gt;
    {% endfor %}
    &lt;/ul&gt;
</code></pre>
<p>But the above code returns the following database error:</p>
<blockquote>
<p>SQLSTATE[42S22]: Column not found: 1054 Unknown column
'structureelements.structureId' in 'group statement' The SQL being
executed was: SELECT <code>elements</code>.<code>id</code>, <code>elements_sites</code>.<code>siteId</code>,
COUNT(*) AS <code>count</code> FROM (SELECT <code>elements</code>.<code>id</code> AS <code>elementsId</code>,
<code>elements_sites</code>.<code>id</code> AS <code>elementsSitesId</code>, <code>content</code>.<code>id</code> AS
<code>contentId</code> FROM <code>elements</code> <code>elements</code></p>
</blockquote>
<p>Unsure how to fix the above?</p>

CC BY-SA 4.0
2020-09-07T03:49:54.837Z
Looks like there's already a GH issue for this: https://github.com/nystudio107/craft-similar/issues/22
Brad Bell
CC BY-SA 4.0
2020-09-07T15:57:58.600Z
You're right Brad! Thanks for answering.
JMKelley
<templating><plugins>
Similar plugin filter results by section
# Similar plugin filter results by section

(Asked by: username_0 on 2020-09-06)

I currently have the Similar plugin on my system, and I'm looking for similar entries by Category. It's working great, but I'm looking to limit the results to a specific section.
    {% set limitCriteria = craft.entries().section('merchants').limit(4) %}
    {% set similarEntriesByCat = craft.similar.find({ element: entry, context: entry.vertical, criteria: limitCriteria }) %}

    
    {% for similarEntry in similarEntriesByCat %}
        {{ similarEntry.title }} ({{ similarEntry.count }} tags in common)
    {% endfor %}
    

But the above code returns the following database error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column
'structureelements.structureId' in 'group statement' The SQL being
executed was: SELECT elements.id, elements_sites.siteId,
COUNT(*) AS count FROM (SELECT elements.id AS elementsId,
elements_sites.id AS elementsSitesId, content.id AS
contentId FROM elements elements

Unsure how to fix the above?

**Tags:** templating, plugins

> **Comments:**
> **username_1**: Looks like there's already a GH issue for this: https://github.com/nystudio107/craft-similar/issues/22  
> **username_0**: You're right Brad! Thanks for answering.  

---

## 0 answers

