diff --git a/search-services/alfresco-search/generator-solr-config/generate-solr-config.py b/search-services/alfresco-search/generator-solr-config/generate-solr-config.py index b23d3152e..927385845 100644 --- a/search-services/alfresco-search/generator-solr-config/generate-solr-config.py +++ b/search-services/alfresco-search/generator-solr-config/generate-solr-config.py @@ -1,4 +1,19 @@ -import itertools +# 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 . +import itertools tokenized = "tokenized" string = "string" diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoSolrDataModel.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoSolrDataModel.java index de57cfd87..7bec1000c 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoSolrDataModel.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoSolrDataModel.java @@ -63,7 +63,6 @@ import org.alfresco.repo.search.impl.parsers.AlfrescoFunctionEvaluationContext; import org.alfresco.repo.search.impl.parsers.FTSParser; import org.alfresco.repo.search.impl.parsers.FTSQueryParser; import org.alfresco.repo.search.impl.querymodel.Constraint; -import org.alfresco.repo.search.impl.querymodel.Ordering; import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryBuilder; @@ -775,7 +774,6 @@ public class AlfrescoSolrDataModel implements QueryConstants } } - // TODO: make it better private void addHighlightSearchFields( PropertyDefinition propertyDefinition , IndexedField indexedField) { @@ -1000,7 +998,6 @@ public class AlfrescoSolrDataModel implements QueryConstants } - public String getStoredContentField(QName propertyQName) { PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName); @@ -1030,7 +1027,6 @@ public class AlfrescoSolrDataModel implements QueryConstants } - /** * Get all the field names into which we must copy the source data * @@ -1592,11 +1588,10 @@ public class AlfrescoSolrDataModel implements QueryConstants } /** - * TODO refactor this method * * return the stored field associated to potentialProperty parameter */ - public String mapStoredProperty(String potentialProperty, FieldUse fieldUse, SolrQueryRequest req) + public String mapStoredProperty(String potentialProperty, SolrQueryRequest req) { if(potentialProperty.equals("asc") || potentialProperty.equals("desc") || potentialProperty.equals("_docid_")) { @@ -1648,7 +1643,7 @@ public class AlfrescoSolrDataModel implements QueryConstants } else { - return mapProperty(potentialProperty, fieldUse, req, 0); + return mapAlfrescoField(FieldUse.FTS, 0, fieldNameAndEnding, luceneField, propertyDef); } } @@ -1689,6 +1684,12 @@ public class AlfrescoSolrDataModel implements QueryConstants propertyDef = getPropertyDefinition(luceneField.substring(index +1)); } } + String solrSortField; + solrSortField = mapAlfrescoField(fieldUse, position, fieldNameAndEnding, luceneField, propertyDef); + return solrSortField; + } + + private String mapAlfrescoField(FieldUse fieldUse, int position, Pair fieldNameAndEnding, String luceneField, PropertyDefinition propertyDef) { String solrSortField; if(propertyDef != null) { diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java index c664c48af..b19707aab 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java @@ -2209,7 +2209,7 @@ public class SolrInformationServer implements InformationServer dataModel.getIndexedFieldNamesForProperty(propertyQName).getFields() .stream() - .filter(field -> field.getField().startsWith("text@sd___@") || field.getField().startsWith("text@m__sort")) + .filter(field -> field.getField().startsWith("text@sd___@")) .forEach(field -> addStringProperty(valueHolder, field, value, locale)); } else { diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/StripLocaleStrField.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/StripLocaleStrField.java index 3caec3f00..132425a4f 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/StripLocaleStrField.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/StripLocaleStrField.java @@ -1,3 +1,21 @@ +/* + * 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 . + */ package org.alfresco.solr; import static java.util.Optional.ofNullable; diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/component/RewriteFieldListComponent.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/component/RewriteFieldListComponent.java index 75fc0c562..22240edee 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/component/RewriteFieldListComponent.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/component/RewriteFieldListComponent.java @@ -1,3 +1,21 @@ +/* + * 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 . + */ package org.alfresco.solr.component; import org.alfresco.solr.AlfrescoSolrDataModel; @@ -39,8 +57,6 @@ public class RewriteFieldListComponent extends SearchComponent { private void transformFieldList(SolrQueryRequest req) { - - Set fieldListSet = new HashSet<>(); Set defaultNonCachedFields = Set.of("id","DBID", "_version_"); @@ -84,15 +100,9 @@ public class RewriteFieldListComponent extends SearchComponent { } else { - - - - List fieldUsed = List.of(FTS, FACET, ID, SORT); fieldListSet.addAll(solrReturnFields.getLuceneFieldNames().stream() - .flatMap(field -> - fieldUsed.stream() - .map( fieldUse -> AlfrescoSolrDataModel.getInstance() - .mapStoredProperty(field, fieldUse, req))) + .map( field -> AlfrescoSolrDataModel.getInstance() + .mapStoredProperty(field, req)) .filter(schemaFieldName -> schemaFieldName != null) .map(schemaFieldName -> schemaFieldName.chars() .mapToObj(c -> (char) c)