Skip to content

Commit

Permalink
fix(strategies): replace deprecated attributesToIndex by `searchabl…
Browse files Browse the repository at this point in the history
…eAttributes`
  • Loading branch information
shortcuts committed Jun 11, 2021
1 parent 3b17693 commit 8f27634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions scraper/src/strategies/algolia_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ def __init__(self):

@staticmethod
def get(config, levels):
attributes_to_index = []
searchable_attributes = []

# We first look for matches in the exact titles
for level in levels:
for selectors_key in config.selectors:
attr_to_index = 'unordered(hierarchy_radio.' + level + ')'
if level in config.selectors[
selectors_key] and attr_to_index not in attributes_to_index:
attributes_to_index.append(
selectors_key] and attr_to_index not in searchable_attributes:
searchable_attributes.append(
'unordered(hierarchy_radio_camel.' + level + ')')
attributes_to_index.append(attr_to_index)
searchable_attributes.append(attr_to_index)

# Then in the whole title hierarchy
for level in levels:
for selectors_key in config.selectors:
attr_to_index = 'unordered(hierarchy.' + level + ')'
if level in config.selectors[
selectors_key] and attr_to_index not in attributes_to_index:
attributes_to_index.append(
selectors_key] and attr_to_index not in searchable_attributes:
searchable_attributes.append(
'unordered(hierarchy_camel.' + level + ')')
attributes_to_index.append(attr_to_index)
searchable_attributes.append(attr_to_index)

for selectors_key in config.selectors:
if 'content' in config.selectors[
selectors_key] and 'content' not in attributes_to_index:
attributes_to_index.append('content')
selectors_key] and 'content' not in searchable_attributes:
searchable_attributes.append('content')

settings = {
'attributesToIndex': attributes_to_index,
'searchableAttributes': searchable_attributes,
'attributesToRetrieve': [
'hierarchy',
'content',
Expand Down
2 changes: 1 addition & 1 deletion scraper/src/tests/default_strategy/get_settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def test_get_settings(self):
'content'
]

assert settings['attributesToIndex'] == expected_settings
assert settings['searchableAttributes'] == expected_settings

0 comments on commit 8f27634

Please sign in to comment.