algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

Exclude a collection from search #38

Closed iloveip closed 8 years ago

iloveip commented 8 years ago

Hi there,

Is it possible to exclude a whole collection from search instead of individual files?

pixelastic commented 8 years ago

Hello,

You should be able to use the custom_hook_each(item) hook to exclude some items based on the attributes of item.

The v1 of the plugin (not yet officially published on RubyGems) adds an attribute collection_name to the collection items. I'll do my best to release the v1 shortly.

iloveip commented 8 years ago

Thank you very much for your reply! I will be looking forward to v1.

iloveip commented 8 years ago

Hi there,

Are there any news on releasing v1?

pixelastic commented 8 years ago

Hello,

I've fallen behind on the schedule of releasing v1 officially, but you can find it here: https://rubygems.org/gems/algoliasearch-jekyll/versions/1.0.0.beta.pre.1

In your Gemfile, specify the version as 1.0.0.beta.pre.1 and you will have the feature discussed above

iloveip commented 8 years ago

Hello,

Thank you very much for your reply. I upgraded to version 1.0.0.beta.pre.1, but then had to go back to the previous version. In version 1.0.0.beta.pre.1 there is missing some information about the records. For example, for each page I have a label, page views and a date. They were displayed in the search results like this:

{% raw %}
  <article class="algolia__result">
    <div class="category-label post-meta label-blue">{{ label }}</div>
    <a class="algolia__result-link" href="{{ full_url }}">
      <h2>
        {{{ _highlightResult.title.value }}}
      </h2>
      <p class="algolia__result-text">{{{ _highlightResult.text.value }}}</p>
    </a>
    <p class="post-meta summary">
      {{#posted_at}}
        <span class="date">{{ posted_at_month }} <span class="spaced">{{ posted_at_year }}</span></span>
      {{/posted_at}}
      <span class="octicon octicon-eye"></span><span class="spaced">{{ views }}</span>
    </p>
  </article>
{% endraw %}

If I use version 1.0.0.beta.pre.1, instead of this information there is only blank space.

pixelastic commented 8 years ago

I'll focus on releasing the official v1 first week of November. I'll handle this issue at that time, sorry about the delay but don't worry, we'll get that fixed :)

iloveip commented 8 years ago

@pixelastic Ok, thank you very much, I will be looking forward to it. And when v1 is released, would this code be correct to exclude a collection from search?

class AlgoliaSearchRecordExtractor
  def custom_hook_each(item, node)
    if node.attr('collection_name') == 'some-title'
      return nil
    end
    item
  end
end
pixelastic commented 8 years ago

I'll have to check, but I think it will more be something like:

class AlgoliaSearchRecordExtractor
  def custom_hook_each(item, node)
    if item.collection_name == 'some-title'
      return nil
    end
    item
  end
end
iloveip commented 8 years ago

@pixelastic Ok, thank you very much!

pixelastic commented 7 years ago

@iloveip I'm sorry I haven't been able to find the time to work on it as I said. I'll do my best but can't really give an ETA. Sorry about that.

iloveip commented 7 years ago

Hi there,

Do you have any updates on releasing v1?

pixelastic commented 7 years ago

Unfortunatly no, I have currently no ETA visibility so I'd rather not say anything as I might not be able to be true to my word :(

Do you have a specific issue that is blocking you?

iloveip commented 7 years ago

@pixelastic ok, I understand.

I have several collections on my site, and I would like to exclude one of them from search. When I tried to upgrade to v.1.0.0.beta.pre.1, I faced an issue, where some information about the records is missing. I described it here https://github.com/algolia/algoliasearch-jekyll/issues/38#issuecomment-254969213. So I had to roll back to the previous version and delete the items from the collection manually. I haven't updated the search records since then, and as I understand I will have to do it manually again.

iloveip commented 7 years ago

Hi there, Do you have any updates on v1?

pixelastic commented 7 years ago

I'd love to be able to give you more news, but so far it hasn't moved. I still want to resurect it, but still don't have an ETA. Sorry I can't tell you more :/