<p>I've done this, and I believe the trick was to return <code>true</code>.</p>

<p>UPDATE: Looks like this was fixed in version 1.5.2, returning false will skip the entry as expected.</p>

CC BY-SA 3.0
2017-07-19T22:37:17.060Z
Interesting... so you're saying I should return `true` instead of `false`? Seems counter-intuitive, but I'll give it a shot!
Lindsey D
CC BY-SA 3.0
2017-07-19T22:34:56.277Z
2018-01-30T19:59:00.393Z
2018-01-30T19:59:00.393Z
Curtis
<p>With the Search Plus plugin, it's possible to define a <a href="https://squarebit.co.uk/software/craft/searchplus/usage/hooks-events#addAlgoliaMapping" rel="nofollow noreferrer">custom mapping</a> of your Entries for your Algolia index. This is basically a two-part process:</p>

<ol>
<li>Call the <code>searchPlus_addAlgoliaMapping</code> to declare <em>which</em> function controls the mapping.</li>
<li>Write the function which controls the mapping.</li>
</ol>

<p>I've done both of these, and it's working very well. Here's an example of my mapping function...</p>

<pre class="lang-php prettyprint-override"><code>return [
    'objectID' =&gt; $entry-&gt;id,
    'uri'      =&gt; $entry-&gt;uri,
    'title'    =&gt; $entry-&gt;title,
];
</code></pre>

<p>However, there are certain entries which should be <strong>excluded</strong> from the search index. My instinct tells me to simply wrap a conditional around that mapping, and return <code>false</code> (or <code>null</code>) for entries which should be excluded...</p>

<pre class="lang-php prettyprint-override"><code>if ($entry-&gt;includeInSearch) {
    return [
        'objectID' =&gt; $entry-&gt;id,
        'uri'      =&gt; $entry-&gt;uri,
        'title'    =&gt; $entry-&gt;title,
    ];
} else {
    return false;
}
</code></pre>

<p>The problem is, this seems to cause an error when Search Plus tries to export to Algolia...</p>

<p><a href="https://i.sstatic.net/5Xvh0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5Xvh0.png" alt="craft_searchplus_indexitem"></a></p>

<p>Which leads to the question: <strong>What is the proper way to omit an entry from an Algolia index?</strong></p>

<entries><plugin-searchplus>
Search Plus - How to skip an entry in mapping?
# Search Plus - How to skip an entry in mapping?

(Asked by: username_0 on 2017-06-13)

With the Search Plus plugin, it's possible to define a custom mapping of your Entries for your Algolia index. This is basically a two-part process:

Call the searchPlus_addAlgoliaMapping to declare which function controls the mapping.
Write the function which controls the mapping.

I've done both of these, and it's working very well. Here's an example of my mapping function...
return [
    'objectID' => $entry->id,
    'uri'      => $entry->uri,
    'title'    => $entry->title,
];

However, there are certain entries which should be excluded from the search index. My instinct tells me to simply wrap a conditional around that mapping, and return false (or null) for entries which should be excluded...
if ($entry->includeInSearch) {
    return [
        'objectID' => $entry->id,
        'uri'      => $entry->uri,
        'title'    => $entry->title,
    ];
} else {
    return false;
}

The problem is, this seems to cause an error when Search Plus tries to export to Algolia...

Which leads to the question: What is the proper way to omit an entry from an Algolia index?

**Tags:** entries, plugin-searchplus


---

## 1 answers

### Answer by username_1 on 2017-07-19. Score: 4 | Accepted answer

I've done this, and I believe the trick was to return `true`.

UPDATE: Looks like this was fixed in version 1.5.2, returning false will skip the entry as expected.

> **Comments:**
> **username_0**: Interesting... so you're saying I should return `true` instead of `false`? Seems counter-intuitive, but I'll give it a shot!  

---

