Files
SearchServices/search-services/alfresco-search/generator-solr-config/generate-solr-config.py
Elia Porciani c555f6d400 Fix/search 2400 to 2.0.x (#937)
* [SEARCH-2400]
restored shared.properties as in 1.4.3

(cherry picked from commit 45fd7b6c83b7f96925a163853ee22cc09c52ba44)

* [SEARCH-2400]
changed music model

(cherry picked from commit f7bbac444de7c2a7ea9bf18e72ea1b43153344c0)

* [SEARCH-2400]
removed conf directory from solrhome in distributed tests

(cherry picked from commit 52c94cef08d1d5646b37074ba42b1ab6ee2ab1c7)

* [SEARCH-2400]
use different shared.properties for integration tests

(cherry picked from commit 61dd7a5df731b2a4e88f6302d89b738b35c6f5f4)

* [SEARCH-2400]
restored music model

(cherry picked from commit b5894e6ddb5a9acbf7a0dd8e4d6c8f0014ed5d69)

* [SEARCh-2400]
restored test to be the same as in 1.4.3 branch

(cherry picked from commit d5c6ced530b4edaae00a8edbde55b9fdffcc6839)

* [SEARCH-2400]
activate cross-locale field for all the non-tokenized properties

(cherry picked from commit e04d486f623407dc3c763f637d3bdd90937364c2)

* [SEARCH-2400]
fixed test on dynamic fields

(cherry picked from commit b336d8ff02f7b7e29202160ef1b8081a37d86c53)

* [SEARCH-2400]
fixed test shared.properties on insightEngine

(cherry picked from commit 5a0738eed5ec1684d2100a15992294963e50431c)

* [SEARCH-2400]
removed check for property with no cross-locale fields in highlighter

(cherry picked from commit a05149503e30556e299e63122acbb5e43dc62ff6)
2020-09-11 14:41:16 +02:00

128 lines
3.7 KiB
Python

# Copyright (C) 2020 Alfresco Software Limited.
# This file is part of Alfresco
#
# Alfresco is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alfresco is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
import itertools
tokenized = "tokenized"
string = "string"
sortable = "sortable"
suggestable = "suggestable"
cross_locale = "cross-locale"
output_file = "generated_copy_fields.xml"
def find_subsets(s, n):
return [set(i) for x in range(1, n+1) for i in itertools.combinations(s, x) ]
def get_copy_field_xml(source, destination):
return '<copyField source="' + source + '" dest="' + destination+ '" />'
def get_dynamic_field_xml(field, field_type):
postfix = ""
if field_type in ("text", "content"):
postfix = '" type="localePrefixedField" />'
else:
postfix = '" type="localePrefixedField" multiValued="true" />'
return '<dynamicField name="'+ field + postfix
def get_field_prefix(field_type):
if field_type == "text":
return "text@s_"
elif field_type == "mltext":
return "mltext@m_"
elif field_type == "content":
return "content@s_"
else:
return "text@m_"
def generate_fields(field_type, tokenized, string, cross_locale, sortable, suggestable):
prefix = get_field_prefix(field_type)
field = prefix + "stored_" + ("t" if tokenized else "_") + ("s" if string else "_") + ("c" if cross_locale else "_") + ("s" if sortable else "_" ) + ("s" if suggestable else "_") + "@*"
generated_fields = []
generated_fields.append(get_dynamic_field_xml(field, field_type))
if tokenized:
generated_fields.append(get_copy_field_xml(field, create_tokenized(prefix)))
if cross_locale:
generated_fields.append(get_copy_field_xml(field, create_tokenized_cross_locale(prefix)))
if string:
generated_fields.append(get_copy_field_xml(field, create_non_tokenized(prefix)))
generated_fields.append(get_copy_field_xml(field, create_non_tokenized_cross_locale(prefix)))
if sortable:
generated_fields.append(get_copy_field_xml(field, create_sortable(prefix)))
if suggestable:
generated_fields.append(get_copy_field_xml(field, "suggest"))
return generated_fields
def create_tokenized(prefix):
return prefix + "_lt" + "@*"
def create_tokenized_cross_locale(prefix):
return prefix + "__t" + "@*"
def create_non_tokenized(prefix):
return prefix + "_l_" + "@*"
def create_non_tokenized_cross_locale(prefix):
return prefix + "___" + "@*"
def create_sortable(prefix):
return prefix + "_sort" + "@*"
def generate_text(file):
for t in ("text", "mltext", "content", "multivalue-text"):
s = {tokenized, string, cross_locale, sortable, suggestable} if t == "text" else {tokenized, string, cross_locale, suggestable}
for s in find_subsets(s, 5):
generated = generate_fields(t, tokenized in s, string in s, cross_locale in s, sortable in s, suggestable in s)
file.writelines(["%s\n" % item for item in generated])
file.write("\n")
file.write("\n")
def main():
file = open(output_file, "w")
file.write('<fields>\n')
generate_text(file)
file.write('</fields>')
file.close()
main()