Skip to content

Commit

Permalink
Merge pull request #1760 from MTG/docvalues_license
Browse files Browse the repository at this point in the history
SOLR schema: convert license to a docValues field for faster faceting
  • Loading branch information
ffont authored Oct 17, 2024
2 parents f4e84af + 0942fac commit 4b5b709
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion freesound/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
# -------------------------------------------------------------------------------
# Search engine

FCW_FILTER_VALUE = '("attribution" OR "creative commons 0")'
FCW_FILTER_VALUE = '("Attribution" OR "Creative Commons 0")'

# Define the names of some of the indexed sound fields which are to be used later
SEARCH_SOUNDS_FIELD_ID = 'sound_id'
Expand Down
6 changes: 1 addition & 5 deletions search/templatetags/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ def display_facet(context, facet_name, facet_title=None):
element['display_value'] = element['value'][element['value'].find("_")+1:]
elif element['value'] == settings.FCW_FILTER_VALUE:
element['display_value'] = "Approved for Free Cultural Works"
elif facet_name == 'license':
# License field in solr is case insensitive and will return facet names in lowercase.
# We need to properly capitalize them to use official CC license names.
element['display_value'] = element['value'].title().replace('Noncommercial', 'NonCommercial')
elif facet_type == 'range':
# Update display value for range facets
gap = sqp.facets[facet_name]['gap']
Expand Down Expand Up @@ -157,4 +153,4 @@ def display_search_option(context, option_name, widget=None):
search_query_processor_options.SearchOptionChoice: 'select',
}.get(type(option), 'text')
label = option.label if option.label else option_name.capitalize().replace('_', ' ')
return {'option': option, 'option_name': option_name, 'label': label, 'widget': widget}
return {'option': option, 'option_name': option_name, 'label': label, 'widget': widget}
4 changes: 2 additions & 2 deletions utils/search/solr9/cores/freesound/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<field name="tag" type="alphaOnlySort" indexed="true" stored="true" required="false" multiValued="true"/>
<field name="is_explicit" type="boolean" indexed="true" stored="true" required="false" />

<field name="license" type="lowercase" indexed="true" stored="true" />
<field name="license" type="string" indexed="false" stored="false" />

<field name="is_remix" type="boolean" indexed="true" stored="true" required="false" />
<field name="was_remixed" type="boolean" indexed="true" stored="true" required="false" />
Expand Down Expand Up @@ -251,4 +251,4 @@
<!-- Other fields -->
<dynamicField name="random_*" type="random" indexed="true" stored="false"/>

</schema>
</schema>

0 comments on commit 4b5b709

Please sign in to comment.