Index: main/plugin-odf/src/org/ametys/odf/contenttype/ODFMetadataIndexer.java =================================================================== --- main/plugin-odf/src/org/ametys/odf/contenttype/ODFMetadataIndexer.java (revision 37604) +++ main/plugin-odf/src/org/ametys/odf/contenttype/ODFMetadataIndexer.java (working copy) @@ -34,6 +34,7 @@ import org.ametys.odf.orgunit.OrgUnit; import org.ametys.plugins.repository.UnknownAmetysObjectException; import org.ametys.plugins.repository.metadata.CompositeMetadata; +import org.ametys.runtime.util.parameter.Enumerator; /** * Metadata indexer specific to ODF contents, which handles synchronized metadata values. @@ -85,16 +86,21 @@ public void indexStringMetadata(CompositeMetadata metadata, String prefix, Content content, Document document, String name, String fieldName, MetadataDefinition definition) throws Exception { super.indexStringMetadata(metadata, prefix, content, document, name, fieldName, definition); - - Set parentOrgUnitsToIndex = new HashSet(); - + if ("orgUnit".equals(name) || "orgUnit_remote".equals(name)) { + Set parentOrgUnitsToIndex = new HashSet(); + Enumerator enumerator = definition.getEnumerator(); + String[] strValues = metadata.getStringArray(name, new String[0]); for (String id : strValues) { if (StringUtils.isNotEmpty(id)) { + // ODF-1163 : Separate orgUnits of + document.add(new Field(getGlobalPrefix() + prefix + fieldName + "Strict", id, Store.YES, enumerator == null ? Index.ANALYZED : Index.NOT_ANALYZED)); + + // Getting orgUnit parents try { OrgUnit ou = _resolver.resolveById(id); @@ -110,19 +116,19 @@ _logger.warn("There's no orgunit to index for id : " + id + ". It is ignored.", ex); } } - } - } - - for (String value : parentOrgUnitsToIndex) - { - document.add(new Field(getGlobalPrefix() + FieldNames.FULL, value, Store.NO, Index.ANALYZED)); - document.add(new Field(getGlobalPrefix() + fieldName, value, Store.YES, definition.getEnumerator() == null ? Index.ANALYZED : Index.NOT_ANALYZED)); - - String[] words = StringUtils.split(value); - for (String word : words) + + // Indexing parent orgUnits + for (String value : parentOrgUnitsToIndex) { - document.add(new Field(getGlobalPrefix() + FieldNames.ALL_NOT_ANALYZED, StringUtils.strip(word, ",?!:()[].{}=").toLowerCase(), Store.NO, Index.NOT_ANALYZED)); + document.add(new Field(getGlobalPrefix() + FieldNames.FULL, value, Store.NO, Index.ANALYZED)); + document.add(new Field(getGlobalPrefix() + fieldName, value, Store.YES, definition.getEnumerator() == null ? Index.ANALYZED : Index.NOT_ANALYZED)); + + String[] words = StringUtils.split(value); + for (String word : words) + { + document.add(new Field(getGlobalPrefix() + FieldNames.ALL_NOT_ANALYZED, StringUtils.strip(word, ",?!:()[].{}=").toLowerCase(), Store.NO, Index.NOT_ANALYZED)); + } } } }