Skip to content

Support replica settings #205

@quytang

Description

@quytang

I came into this issue when trying to implement the sorting feature.
I need to create an index for each sorting criteria.

class ProductIndex(AlgoliaIndex):
    ...
    settings = {
        'attributesToIndex': ['title'],
        'attributesForFaceting': ['country', 'city', 'price', 'status'],
        'replicas': [
            'product_by_title_asc',
            'product_by_title_desc',
            ...
        ]
    }
    index_name = 'product'

Unfortunately, it doesn't work and throws the error

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 356, in execute
output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/django/contrib/algoliasearch/management/commands/algolia_reindex.py", line 22, in
 handle
    batch_size=options.get('batchsize', 1000))
  File "/usr/local/lib/python2.7/site-packages/django/contrib/algoliasearch/models.py", line 241, in reindex_all
    self.__client.move_index(self.index_name + '_tmp', self.index_name)
  File "/usr/local/lib/python2.7/site-packages/algoliasearch/client.py", line 282, in move_index
    return self._req(False, path, 'POST', data=request)
  File "/usr/local/lib/python2.7/site-packages/algoliasearch/client.py", line 542, in _req
    return self._transport.req(is_search, path, meth, params, data)
  File "/usr/local/lib/python2.7/site-packages/algoliasearch/transport.py", line 166, in req
    raise e
algoliasearch.helpers.AlgoliaException: cannot move with a primary/replica index as source

I also need to config the ranking/custom ranking function for each replica index but couldn't find the way to deal with it.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions