Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Use instances for index filtering from callbacks. - #1171

Merged
pat merged 3 commits into
developfrom
index-instance-filtering
Jun 22, 2020
Merged

pat merged 3 commits into
developfrom
index-instance-filtering

Conversation

@pat

@pat pat commented Jun 22, 2020

Copy link
Copy Markdown
Owner

Prompted by discussions in #1166, this PR changes the IndexSet class to accept :instances alongside the :classes option, which could allow custom subclasses of IndexSet to filter returned indices to a subset as determined by the provided instances.

In particular, if you're sharding your indices, you can return just the specific shard of indices for the instance, rather than all shards:

class IndexSet < ThinkingSphinx::IndexSet
  private

  def indices
    return super if instances.empty?

    super.select do |index|
      # shard_id or equivalent logic needs to be implemented.
      # this would return all core and delta indices for the instance's model,
      # filtered by the shard id for the instance.
      instances.any? { |instance| index.name[/_#{instance.shard_id}_$/] }
    end
  end
end

# This line would go in an initialiser:
ThinkingSphinx::Configuration.instance.index_set_class = IndexSet

While it's not necessary moving forward, I'm still passing through the :classes option for anyone who's got a custom IndexSet class that depends on that.

pat added 3 commits June 22, 2020 10:27
We’re going to still pass in the `:classes` option for the moment, for the sake of anyone who’s got a custom IndexSet that relies on that option when managing callbacks.
@pat
pat merged commit c418021 into develop Jun 22, 2020
@pat
pat deleted the index-instance-filtering branch December 21, 2021 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant