Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support replica index configuration #275

Merged

Conversation

johnnynotsolucky
Copy link
Contributor

@johnnynotsolucky johnnynotsolucky commented Oct 4, 2023

Resolves #114

This PR adds a flag on ScoutIndex to flag an index as a replica which prevents it from being sync'd by the plugin.

Replica indices can be configured by adding them to the indices property in config like you would a regular index with the exception of setting the flag using ->replicaIndex(true).

[
    'indices' => [
        ScoutIndex::create('Products')
            // ...
            ->indexSettings(
                IndexSettings::create()->replicas(['virtual(Products_desc)'])
            )
    ],
    [
        ScoutIndex::create('Products_desc')
            ->replicaIndex(true)
            ->indexSettings(IndexSettings::create()->customRanking(['desc(price)'])),
    ],
]

This roughly follows how Algolia recommends configuring replicas in code: https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-by-attribute/#example-relevant-sort-with-a-virtual-replica

Updated utilities view:

image

@janhenckens janhenckens self-requested a review October 10, 2023 13:49
@janhenckens janhenckens added the linear Created by Linear-GitHub Sync label Oct 10, 2023
@janhenckens
Copy link
Member

Thanks @johnnynotsolucky, I'll have a look and if all goes well this should be included in the next release!

@janhenckens janhenckens changed the base branch from master to develop October 12, 2023 17:40
janhenckens added a commit that referenced this pull request Oct 12, 2023
@janhenckens janhenckens merged commit c20a59f into studioespresso:develop Oct 12, 2023
4 checks passed
janhenckens added a commit that referenced this pull request Oct 12, 2023
@janhenckens
Copy link
Member

Looks good, merged and ready for release. Waiting for a couple of other things but this should be out Sunday at the latest!

Thanks again!

@johnnynotsolucky johnnynotsolucky deleted the replica-indices branch October 12, 2023 17:51
@janhenckens
Copy link
Member

This is now out in 3.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to set index settings on replicas
2 participants