001/* 002 * (C) Copyright 2006-2018 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019 020package org.nuxeo.ecm.core.api.repository; 021 022import java.util.HashMap; 023import java.util.HashSet; 024import java.util.LinkedHashSet; 025import java.util.Map; 026import java.util.Set; 027 028/** 029 * Info about the fulltext configuration. 030 * 031 * @since 10.3 in this package 032 */ 033public class FulltextConfiguration { 034 035 public static final String ROOT_TYPE = "Root"; 036 037 /** All index names. */ 038 public final Set<String> indexNames = new LinkedHashSet<>(); 039 040 /** Indexes holding exactly one field. */ 041 public final Map<String, String> fieldToIndexName = new HashMap<>(); 042 043 /** Indexes containing all simple properties. */ 044 public final Set<String> indexesAllSimple = new HashSet<>(); 045 046 /** Indexes containing all binaries properties. */ 047 public final Set<String> indexesAllBinary = new HashSet<>(); 048 049 /** Indexes for each specific simple property path. */ 050 public final Map<String, Set<String>> indexesByPropPathSimple = new HashMap<>(); 051 052 /** Indexes for each specific binary property path. */ 053 // DBSTransactionState.findDirtyDocuments expects this to contain unprefixed versions for schemas 054 // without prefix, like "content/data". 055 public final Map<String, Set<String>> indexesByPropPathBinary = new HashMap<>(); 056 057 /** Indexes for each specific simple property path excluded. */ 058 public final Map<String, Set<String>> indexesByPropPathExcludedSimple = new HashMap<>(); 059 060 /** Indexes for each specific binary property path excluded. */ 061 public final Map<String, Set<String>> indexesByPropPathExcludedBinary = new HashMap<>(); 062 063 // inverse of above maps 064 public final Map<String, Set<String>> propPathsByIndexSimple = new HashMap<>(); 065 066 public final Map<String, Set<String>> propPathsByIndexBinary = new HashMap<>(); 067 068 public final Map<String, Set<String>> propPathsExcludedByIndexSimple = new HashMap<>(); 069 070 public final Map<String, Set<String>> propPathsExcludedByIndexBinary = new HashMap<>(); 071 072 public final Set<String> excludedTypes = new HashSet<>(); 073 074 public final Set<String> includedTypes = new HashSet<>(); 075 076 public boolean fulltextSearchDisabled; 077 078 public int fulltextFieldSizeLimit; 079 080 public boolean isFulltextIndexable(String typeName) { 081 if (ROOT_TYPE.equals(typeName)) { 082 return false; 083 } 084 if (includedTypes.contains(typeName) || (includedTypes.isEmpty() && !excludedTypes.contains(typeName))) { 085 return true; 086 } 087 return false; 088 } 089 090}