Merge Request #1

Merged
Created by Gethin James

Feature/search 106 highlighting

Adds Search highlighting to the SearchParameters Java Object and ResultSetSPI response. Also depends on Jackson annotations for the object constructor.

//cc @jvonka

Assignee: Derek Hulley
Milestone: None

Merged by Gethin James

Source branch has been removed
Commits (4)
3 participants
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2 <modelVersion>4.0.0</modelVersion> 2 <modelVersion>4.0.0</modelVersion>
3 3
4 <parent> 4 <parent>
5 <groupId>org.alfresco</groupId> 5 <groupId>org.alfresco</groupId>
6 <artifactId>alfresco-super-pom</artifactId> 6 <artifactId>alfresco-super-pom</artifactId>
7 <version>6</version> 7 <version>6</version>
8 </parent> 8 </parent>
9 9
10 <artifactId>alfresco-data-model</artifactId> 10 <artifactId>alfresco-data-model</artifactId>
11 <name>Alfresco Data Model</name> 11 <name>Alfresco Data Model</name>
12 <description>Alfresco Data Model classes</description> 12 <description>Alfresco Data Model classes</description>
13 <version>6.1-SNAPSHOT</version> 13 <version>6.1-SNAPSHOT</version>
14 14
15 <scm> 15 <scm>
16 <connection>scm:git:https://gitlab.alfresco.com/platform/alfresco-data-model.git</connection> 16 <connection>scm:git:https://gitlab.alfresco.com/platform/alfresco-data-model.git</connection>
17 <developerConnection>scm:git:https://gitlab.alfresco.com/platform/alfresco-data-model.git</developerConnection> 17 <developerConnection>scm:git:https://gitlab.alfresco.com/platform/alfresco-data-model.git</developerConnection>
18 <url>https://gitlab.alfresco.com/platform/alfresco-data-model</url> 18 <url>https://gitlab.alfresco.com/platform/alfresco-data-model</url>
19 <tag>HEAD</tag> 19 <tag>HEAD</tag>
20 </scm> 20 </scm>
21 21
22 <distributionManagement> 22 <distributionManagement>
23 <repository> 23 <repository>
24 <id>alfresco-internal</id> 24 <id>alfresco-internal</id>
25 <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url> 25 <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
26 </repository> 26 </repository>
27 <snapshotRepository> 27 <snapshotRepository>
28 <id>alfresco-internal-snapshots</id> 28 <id>alfresco-internal-snapshots</id>
29 <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url> 29 <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url>
30 </snapshotRepository> 30 </snapshotRepository>
31 </distributionManagement> 31 </distributionManagement>
32 32
33 <properties> 33 <properties>
34 <!-- Files to exclude from SonarQube analysis --> 34 <!-- Files to exclude from SonarQube analysis -->
35 <sonar.exclusions> 35 <sonar.exclusions>
36 source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java, 36 source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java,
37 source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java, 37 source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java,
38 source/java/org/alfresco/repo/search/impl/parsers/FTSLexer.java 38 source/java/org/alfresco/repo/search/impl/parsers/FTSLexer.java
39 </sonar.exclusions> 39 </sonar.exclusions>
40 40
41 </properties> 41 </properties>
42 42
43 <build> 43 <build>
44 <plugins> 44 <plugins>
45 <plugin> 45 <plugin>
46 <groupId>org.jibx</groupId> 46 <groupId>org.jibx</groupId>
47 <artifactId>maven-jibx-plugin</artifactId> 47 <artifactId>maven-jibx-plugin</artifactId>
48 <configuration> 48 <configuration>
49 <load>true</load> 49 <load>true</load>
50 <schemaBindingDirectory>${project.build.sourceDirectory}/org/alfresco/repo/dictionary</schemaBindingDirectory> 50 <schemaBindingDirectory>${project.build.sourceDirectory}/org/alfresco/repo/dictionary</schemaBindingDirectory>
51 <includeSchemaBindings> 51 <includeSchemaBindings>
52 <includeSchemaBinding>m2binding.xml</includeSchemaBinding> 52 <includeSchemaBinding>m2binding.xml</includeSchemaBinding>
53 </includeSchemaBindings> 53 </includeSchemaBindings>
54 </configuration> 54 </configuration>
55 <executions> 55 <executions>
56 <execution> 56 <execution>
57 <id>bind-sources</id> 57 <id>bind-sources</id>
58 <goals> 58 <goals>
59 <goal>bind</goal> 59 <goal>bind</goal>
60 </goals> 60 </goals>
61 </execution> 61 </execution>
62 </executions> 62 </executions>
63 </plugin> 63 </plugin>
64 64
65 <!-- ACE-3329 Create _en.properties message files --> 65 <!-- ACE-3329 Create _en.properties message files -->
66 <plugin> 66 <plugin>
67 <artifactId>maven-antrun-plugin</artifactId> 67 <artifactId>maven-antrun-plugin</artifactId>
68 <executions> 68 <executions>
69 <execution> 69 <execution>
70 <id>duplicate-english-messages</id> 70 <id>duplicate-english-messages</id>
71 <phase>generate-resources</phase> 71 <phase>generate-resources</phase>
72 <goals> 72 <goals>
73 <goal>run</goal> 73 <goal>run</goal>
74 </goals> 74 </goals>
75 </execution> 75 </execution>
76 </executions> 76 </executions>
77 <configuration> 77 <configuration>
78 <target> 78 <target>
79 <copy todir="${project.build.outputDirectory}"> 79 <copy todir="${project.build.outputDirectory}">
80 <fileset dir="${basedir}/src/main/resources" includes="alfresco/messages/**/*.properties" /> 80 <fileset dir="${basedir}/src/main/resources" includes="alfresco/messages/**/*.properties" />
81 <mapper type="regexp" from="^([^_]*).properties$" to="\1_en.properties" /> 81 <mapper type="regexp" from="^([^_]*).properties$" to="\1_en.properties" />
82 </copy> 82 </copy>
83 </target> 83 </target>
84 </configuration> 84 </configuration>
85 </plugin> 85 </plugin>
86 <plugin> 86 <plugin>
87 <artifactId>maven-jar-plugin</artifactId> 87 <artifactId>maven-jar-plugin</artifactId>
88 <version>2.6</version> 88 <version>2.6</version>
89 <executions> 89 <executions>
90 <execution> 90 <execution>
91 <goals> 91 <goals>
92 <goal>test-jar</goal> 92 <goal>test-jar</goal>
93 </goals> 93 </goals>
94 </execution> 94 </execution>
95 </executions> 95 </executions>
96 </plugin> 96 </plugin>
97 </plugins> 97 </plugins>
98 98
99 <pluginManagement> 99 <pluginManagement>
100 <plugins> 100 <plugins>
101 <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> 101 <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
102 <plugin> 102 <plugin>
103 <groupId>org.eclipse.m2e</groupId> 103 <groupId>org.eclipse.m2e</groupId>
104 <artifactId>lifecycle-mapping</artifactId> 104 <artifactId>lifecycle-mapping</artifactId>
105 <version>1.0.0</version> 105 <version>1.0.0</version>
106 <configuration> 106 <configuration>
107 <lifecycleMappingMetadata> 107 <lifecycleMappingMetadata>
108 <pluginExecutions> 108 <pluginExecutions>
109 <pluginExecution> 109 <pluginExecution>
110 <pluginExecutionFilter> 110 <pluginExecutionFilter>
111 <groupId>org.jibx</groupId> 111 <groupId>org.jibx</groupId>
112 <artifactId> 112 <artifactId>
113 maven-jibx-plugin 113 maven-jibx-plugin
114 </artifactId> 114 </artifactId>
115 <versionRange> 115 <versionRange>
116 [1.2.5,) 116 [1.2.5,)
117 </versionRange> 117 </versionRange>
118 <goals> 118 <goals>
119 <goal>bind</goal> 119 <goal>bind</goal>
120 </goals> 120 </goals>
121 </pluginExecutionFilter> 121 </pluginExecutionFilter>
122 <action> 122 <action>
123 <execute> 123 <execute>
124 <runOnConfiguration>true</runOnConfiguration> 124 <runOnConfiguration>true</runOnConfiguration>
125 <runOnIncremental>true</runOnIncremental> 125 <runOnIncremental>true</runOnIncremental>
126 </execute> 126 </execute>
127 </action> 127 </action>
128 </pluginExecution> 128 </pluginExecution>
129 </pluginExecutions> 129 </pluginExecutions>
130 </lifecycleMappingMetadata> 130 </lifecycleMappingMetadata>
131 </configuration> 131 </configuration>
132 </plugin> 132 </plugin>
133 <plugin> 133 <plugin>
134 <artifactId>maven-release-plugin</artifactId> 134 <artifactId>maven-release-plugin</artifactId>
135 <configuration> 135 <configuration>
136 <autoVersionSubmodules>true</autoVersionSubmodules> 136 <autoVersionSubmodules>true</autoVersionSubmodules>
137 <tagNameFormat>@{project.version}</tagNameFormat> 137 <tagNameFormat>@{project.version}</tagNameFormat>
138 </configuration> 138 </configuration>
139 </plugin> 139 </plugin>
140 </plugins> 140 </plugins>
141 </pluginManagement> 141 </pluginManagement>
142 </build> 142 </build>
143 143
144 <dependencies> 144 <dependencies>
145 <dependency> 145 <dependency>
146 <groupId>org.alfresco</groupId> 146 <groupId>org.alfresco</groupId>
147 <artifactId>alfresco-core</artifactId> 147 <artifactId>alfresco-core</artifactId>
148 <version>6.5</version> 148 <version>6.5</version>
149 </dependency> 149 </dependency>
150 <!-- 150 <!--
151 | provided dependencies (are not transitive and not included in webapps) 151 | provided dependencies (are not transitive and not included in webapps)
152 | see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope 152 | see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
153 --> 153 -->
154 <dependency> 154 <dependency>
155 <groupId>javax.servlet</groupId> 155 <groupId>javax.servlet</groupId>
156 <artifactId>servlet-api</artifactId> 156 <artifactId>servlet-api</artifactId>
157 <version>2.5</version> 157 <version>2.5</version>
158 <scope>provided</scope> 158 <scope>provided</scope>
159 </dependency> 159 </dependency>
160 <!-- 160 <!--
161 | compile dependencies 161 | compile dependencies
162 --> 162 -->
163 <dependency> 163 <dependency>
164 <groupId>jaxen</groupId> 164 <groupId>jaxen</groupId>
165 <artifactId>jaxen</artifactId> 165 <artifactId>jaxen</artifactId>
166 <version>1.1.6</version> 166 <version>1.1.6</version>
167 </dependency> 167 </dependency>
168 <dependency> 168 <dependency>
169 <groupId>org.jibx</groupId> 169 <groupId>org.jibx</groupId>
170 <artifactId>jibx-run</artifactId> 170 <artifactId>jibx-run</artifactId>
171 <version>1.2.6</version> 171 <version>1.2.6</version>
172 </dependency> 172 </dependency>
173 173
174 <dependency> 174 <dependency>
175 <groupId>org.codehaus.jackson</groupId>
176 <artifactId>jackson-core-asl</artifactId>
177 <version>1.9.13</version>
178 </dependency>
179
180 <dependency>
175 <groupId>org.codehaus.jackson</groupId> 181 <groupId>org.antlr</groupId>
176 <artifactId>jackson-core-asl</artifactId> 182 <artifactId>antlr</artifactId>
177 <version>1.9.13</version> 183 <version>3.5.2</version>
178 </dependency> 184 </dependency>
179 185 <dependency>
180 <dependency> 186 <groupId>org.apache.chemistry.opencmis</groupId>
181 <groupId>org.antlr</groupId> 187 <artifactId>chemistry-opencmis-client-impl</artifactId>
182 <artifactId>antlr</artifactId> 188 <version>0.11.0</version>
183 <version>3.5.2</version> 189 <exclusions>
184 </dependency> 190 <exclusion>
185 <dependency> 191 <groupId>junit</groupId>
186 <groupId>org.apache.chemistry.opencmis</groupId> 192 <artifactId>junit</artifactId>
187 <artifactId>chemistry-opencmis-client-impl</artifactId> 193 </exclusion>
188 <version>0.11.0</version> 194 <exclusion>
189 <exclusions> 195 <groupId>org.jvnet.staxex</groupId>
190 <exclusion> 196 <artifactId>stax-ex</artifactId>
191 <groupId>junit</groupId> 197 </exclusion>
192 <artifactId>junit</artifactId> 198 </exclusions>
193 </exclusion> 199 </dependency>
194 <exclusion> 200 <dependency>
195 <groupId>org.jvnet.staxex</groupId> 201 <groupId>org.apache.chemistry.opencmis</groupId>
196 <artifactId>stax-ex</artifactId> 202 <artifactId>chemistry-opencmis-commons-impl</artifactId>
197 </exclusion> 203 <version>0.11.0</version>
198 </exclusions> 204 <exclusions>
199 </dependency> 205 <exclusion>
200 <dependency> 206 <groupId>com.sun.xml.messaging.saaj</groupId>
201 <groupId>org.apache.chemistry.opencmis</groupId> 207 <artifactId>saaj-impl</artifactId>
202 <artifactId>chemistry-opencmis-commons-impl</artifactId> 208 </exclusion>
203 <version>0.11.0</version> 209 <exclusion>
204 <exclusions> 210 <groupId>org.jvnet.staxex</groupId>
205 <exclusion> 211 <artifactId>stax-ex</artifactId>
206 <groupId>com.sun.xml.messaging.saaj</groupId> 212 </exclusion>
207 <artifactId>saaj-impl</artifactId> 213 </exclusions>
208 </exclusion> 214 </dependency>
209 <exclusion> 215 <!-- stax-ex is exluded from chemistry and included here, to avoid making constant requests to the repo -->
210 <groupId>org.jvnet.staxex</groupId> 216 <!-- That's becausde the chemistry-pulled one does not specify a specific version -->
211 <artifactId>stax-ex</artifactId> 217 <dependency>
212 </exclusion> 218 <groupId>org.jvnet.staxex</groupId>
213 </exclusions> 219 <artifactId>stax-ex</artifactId>
214 </dependency> 220 <version>1.2</version>
215 <!-- stax-ex is exluded from chemistry and included here, to avoid making constant requests to the repo --> 221 </dependency>
216 <!-- That's becausde the chemistry-pulled one does not specify a specific version --> 222 <dependency>
217 <dependency> 223 <groupId>org.apache.chemistry.opencmis</groupId>
218 <groupId>org.jvnet.staxex</groupId> 224 <artifactId>chemistry-opencmis-server-bindings</artifactId>
219 <artifactId>stax-ex</artifactId> 225 <version>0.11.0</version>
220 <version>1.2</version> 226 <exclusions>
221 </dependency> 227 <exclusion>
222 <dependency> 228 <groupId>org.jvnet.staxex</groupId>
223 <groupId>org.apache.chemistry.opencmis</groupId> 229 <artifactId>stax-ex</artifactId>
224 <artifactId>chemistry-opencmis-server-bindings</artifactId> 230 </exclusion>
225 <version>0.11.0</version> 231 </exclusions>
226 <exclusions> 232 </dependency>
227 <exclusion> 233 <dependency>
228 <groupId>org.jvnet.staxex</groupId> 234 <groupId>org.codehaus.woodstox</groupId>
229 <artifactId>stax-ex</artifactId> 235 <artifactId>woodstox-core-asl</artifactId>
230 </exclusion> 236 <version>4.2.0</version>
231 </exclusions> 237 </dependency>
232 </dependency> 238 <!-- This is now deployed at:
233 <dependency> 239 | http://artifacts.alfresco.com/nexus/content/repositories/thirdparty/org/acegisecurity/acegi-security/0.8.2_patched/
234 <groupId>org.codehaus.woodstox</groupId> 240 -->
235 <artifactId>woodstox-core-asl</artifactId> 241 <dependency>
236 <version>4.2.0</version> 242 <groupId>org.acegisecurity</groupId>
237 </dependency> 243 <artifactId>acegi-security</artifactId>
238 <!-- This is now deployed at: 244 <version>0.8.2_patched</version>
239 | http://artifacts.alfresco.com/nexus/content/repositories/thirdparty/org/acegisecurity/acegi-security/0.8.2_patched/ 245 </dependency>
240 --> 246 <dependency>
241 <dependency> 247 <groupId>org.alfresco</groupId>
242 <groupId>org.acegisecurity</groupId> 248 <artifactId>alfresco-xmlfactory</artifactId>
243 <artifactId>acegi-security</artifactId> 249 <version>1.2</version>
244 <version>0.8.2_patched</version> 250 </dependency>
245 </dependency> 251 <dependency>
246 <dependency> 252 <groupId>xerces</groupId>
247 <groupId>org.alfresco</groupId> 253 <artifactId>xercesImpl</artifactId>
248 <artifactId>alfresco-xmlfactory</artifactId> 254 <version>2.10.0-alfresco-patched</version>
249 <version>1.2</version> 255 </dependency>
250 </dependency> 256 <dependency>
251 <dependency> 257 <groupId>xpp3</groupId>
252 <groupId>xerces</groupId> 258 <artifactId>xpp3</artifactId>
253 <artifactId>xercesImpl</artifactId> 259 <version>1.1.3_8</version>
254 <version>2.10.0-alfresco-patched</version> 260 </dependency>
255 </dependency> 261 <!-- Tika -->
256 <dependency> 262 <dependency>
257 <groupId>xpp3</groupId> 263 <groupId>org.apache.tika</groupId>
258 <artifactId>xpp3</artifactId> 264 <artifactId>tika-core</artifactId>
259 <version>1.1.3_8</version> 265 <version>1.6-20160727-alfresco-patched</version>
260 </dependency> 266 </dependency>
261 <!-- Tika --> 267 <dependency>
262 <dependency> 268 <groupId>org.apache.tika</groupId>
263 <groupId>org.apache.tika</groupId> 269 <artifactId>tika-parsers</artifactId>
264 <artifactId>tika-core</artifactId> 270 <version>1.6-20160727-alfresco-patched</version>
265 <version>1.6-20160727-alfresco-patched</version> 271 </dependency>
266 </dependency> 272 <dependency>
267 <dependency> 273 <groupId>org.gagravarr</groupId>
268 <groupId>org.apache.tika</groupId> 274 <artifactId>vorbis-java-core</artifactId>
269 <artifactId>tika-parsers</artifactId> 275 <version>0.4</version>
270 <version>1.6-20160727-alfresco-patched</version> 276 </dependency>
271 </dependency> 277 <dependency>
272 <dependency> 278 <groupId>org.gagravarr</groupId>
273 <groupId>org.gagravarr</groupId> 279 <artifactId>vorbis-java-tika</artifactId>
274 <artifactId>vorbis-java-core</artifactId> 280 <version>0.4</version>
275 <version>0.4</version> 281 </dependency>
276 </dependency> 282 <dependency>
277 <dependency> 283 <groupId>com.googlecode.juniversalchardet</groupId>
278 <groupId>org.gagravarr</groupId> 284 <artifactId>juniversalchardet</artifactId>
279 <artifactId>vorbis-java-tika</artifactId> 285 <version>1.0.3</version>
280 <version>0.4</version> 286 </dependency>
281 </dependency> 287
282 <dependency> 288 <!-- Test dependencies -->
283 <groupId>com.googlecode.juniversalchardet</groupId> 289 <dependency>
284 <artifactId>juniversalchardet</artifactId> 290 <groupId>junit</groupId>
285 <version>1.0.3</version> 291 <artifactId>junit</artifactId>
286 </dependency> 292 <version>4.12</version>
287 293 <scope>test</scope>
288 <!-- Test dependencies --> 294 </dependency>
289 <dependency> 295 <dependency>
290 <groupId>junit</groupId> 296 <groupId>org.antlr</groupId>
291 <artifactId>junit</artifactId> 297 <artifactId>gunit</artifactId>
292 <version>4.12</version> 298 <version>3.5.2</version>
293 <scope>test</scope> 299 <scope>test</scope>
294 </dependency> 300 </dependency>
295 <dependency> 301 <dependency>
296 <groupId>org.antlr</groupId> 302 <groupId>org.mockito</groupId>
297 <artifactId>gunit</artifactId> 303 <artifactId>mockito-all</artifactId>
298 <version>3.5.2</version> 304 <version>1.10.19</version>
299 <scope>test</scope> 305 <scope>test</scope>
300 </dependency> 306 </dependency>
301 <dependency> 307 </dependencies>
302 <groupId>org.mockito</groupId> 308
303 <artifactId>mockito-all</artifactId> 309 <profiles>
304 <version>1.10.19</version> 310 <profile>
305 <scope>test</scope> 311 <id>doclint-java8-max</id>
306 </dependency> 312 <activation>
307 </dependencies> 313 <jdk>[1.8,)</jdk>
308 314 </activation>
309 <profiles> 315 <build>
310 <profile> 316 <plugins>
311 <id>doclint-java8-max</id> 317 <plugin>
312 <activation> 318 <artifactId>maven-javadoc-plugin</artifactId>
313 <jdk>[1.8,)</jdk> 319 <configuration>
314 </activation> 320 <!-- <additionalparam>-Xmaxwarns 10000 -Xmaxerrs 10000</additionalparam> to detect more than 100 error -->
315 <build> 321 <additionalparam>-Xdoclint:none</additionalparam>
316 <plugins> 322 </configuration>
317 <plugin> 323 </plugin>
318 <artifactId>maven-javadoc-plugin</artifactId> 324 </plugins>
319 <configuration> 325 </build>
320 <!-- <additionalparam>-Xmaxwarns 10000 -Xmaxerrs 10000</additionalparam> to detect more than 100 error --> 326 </profile>
321 <additionalparam>-Xdoclint:none</additionalparam> 327 </profiles>
322 </configuration> 328 </project>
323 </plugin> 329
src/main/java/org/alfresco/service/cmr/search/FieldHighlightParameters.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.service.cmr.search;
27
28 import org.alfresco.api.AlfrescoPublicApi;
29 import org.codehaus.jackson.annotate.JsonCreator;
30 import org.codehaus.jackson.annotate.JsonProperty;
31
32 /**
33 * Parameters used for search hightlighting that are Field Specific
34 */
35
36 @AlfrescoPublicApi
37 public class FieldHighlightParameters extends HighlightParameters
38 {
39 private final String field;
40
41 @JsonCreator
42 public FieldHighlightParameters(
43 @JsonProperty("field") String field,
44 @JsonProperty("snippetCount") Integer snippetCount,
45 @JsonProperty("fragmentSize") Integer fragmentSize,
46 @JsonProperty("mergeContiguous") Boolean mergeContiguous,
47 @JsonProperty("prefix") String prefix,
48 @JsonProperty("postfix") String postfix)
49 {
50 super(snippetCount, fragmentSize, mergeContiguous, prefix, postfix);
51 this.field = field;
52 }
53
54 @Override
55 public String toString()
56 {
57 return "FieldHighlightParameters{" +
58 "snippetCount=" + snippetCount +
59 ", fragmentSize=" + fragmentSize +
60 ", mergeContiguous=" + mergeContiguous +
61 ", prefix='" + prefix + '\'' +
62 ", postfix='" + postfix + '\'' +
63 ", field='" + field + '\'' +
64 '}';
65 }
66
67 public String getField()
68 {
69 return field;
70 }
71
72 @Override
73 public boolean equals(Object o)
74 {
75 if (this == o)
76 return true;
77 if (o == null || getClass() != o.getClass())
78 return false;
79 if (!super.equals(o))
80 return false;
81
82 FieldHighlightParameters that = (FieldHighlightParameters) o;
83
84 if (field != null ? !field.equals(that.field) : that.field != null)
85 return false;
86
87 return true;
88 }
89
90 @Override
91 public int hashCode()
92 {
93 int result = super.hashCode();
94 result = 31 * result + (field != null ? field.hashCode() : 0);
95 return result;
96 }
97 }
1 /* 98
src/main/java/org/alfresco/service/cmr/search/GeneralHighlightParameters.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.service.cmr.search;
27
28 import org.alfresco.api.AlfrescoPublicApi;
29 import org.codehaus.jackson.annotate.JsonCreator;
30 import org.codehaus.jackson.annotate.JsonProperty;
31
32 import java.util.List;
33
34 /**
35 * Parameters used for search hightlighting that apply to all fields
36 */
37
38 @AlfrescoPublicApi
39 public class GeneralHighlightParameters extends HighlightParameters
40 {
41 private final Integer maxAnalyzedChars;
42 private final Boolean usePhraseHighlighter;
43
44 private final List<FieldHighlightParameters> fields;
45
46 @JsonCreator
47 public GeneralHighlightParameters(
48 @JsonProperty("snippetCount") Integer snippetCount,
49 @JsonProperty("fragmentSize") Integer fragmentSize,
50 @JsonProperty("mergeContiguous") Boolean mergeContiguous,
51 @JsonProperty("prefix") String prefix,
52 @JsonProperty("postfix") String postfix,
53 @JsonProperty("maxAnalyzedChars") Integer maxAnalyzedChars,
54 @JsonProperty("usePhraseHighlighter") Boolean usePhraseHighlighter,
55 @JsonProperty("fields") List<FieldHighlightParameters> fields)
56 {
57 super(snippetCount, fragmentSize, mergeContiguous, prefix, postfix);
58 this.maxAnalyzedChars = maxAnalyzedChars;
59 this.usePhraseHighlighter = usePhraseHighlighter;
60 this.fields = fields;
61 }
62
63 @Override
64 public String toString()
65 {
66 return "GeneralHighlightParameters{" +
67 "snippetCount=" + snippetCount +
68 ", fragmentSize=" + fragmentSize +
69 ", mergeContiguous=" + mergeContiguous +
70 ", prefix='" + prefix + '\'' +
71 ", postfix='" + postfix + '\'' +
72 ", maxAnalyzedChars=" + maxAnalyzedChars +
73 ", usePhraseHighlighter=" + usePhraseHighlighter +
74 ", fields=" + fields +
75 '}';
76 }
77
78 @Override
79 public boolean equals(Object o)
80 {
81 if (this == o)
82 return true;
83 if (o == null || getClass() != o.getClass())
84 return false;
85 if (!super.equals(o))
86 return false;
87
88 GeneralHighlightParameters that = (GeneralHighlightParameters) o;
89
90 if (getMaxAnalyzedChars() != null ? !getMaxAnalyzedChars().equals(that.getMaxAnalyzedChars()) : that.getMaxAnalyzedChars() != null)
91 return false;
92 if (getUsePhraseHighlighter() != null ?
93 !getUsePhraseHighlighter().equals(that.getUsePhraseHighlighter()) :
94 that.getUsePhraseHighlighter() != null)
95 return false;
96 if (getFields() != null ? !getFields().equals(that.getFields()) : that.getFields() != null)
97 return false;
98
99 return true;
100 }
101
102 @Override
103 public int hashCode()
104 {
105 int result = super.hashCode();
106 result = 31 * result + (getMaxAnalyzedChars() != null ? getMaxAnalyzedChars().hashCode() : 0);
107 result = 31 * result + (getUsePhraseHighlighter() != null ? getUsePhraseHighlighter().hashCode() : 0);
108 result = 31 * result + (getFields() != null ? getFields().hashCode() : 0);
109 return result;
110 }
111
112 public Integer getMaxAnalyzedChars()
113 {
114 return maxAnalyzedChars;
115 }
116
117 public Boolean getUsePhraseHighlighter()
118 {
119 return usePhraseHighlighter;
120 }
121
122 public List<FieldHighlightParameters> getFields()
123 {
124 return fields;
125 }
126
127 }
1 /* 128
src/main/java/org/alfresco/service/cmr/search/HighlightParameters.java
File was created 1 /*
2 * #%L
3 * Alfresco Data model classes
4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %%
7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms:
11 *
12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L%
25 */
26 package org.alfresco.service.cmr.search;
27
28 import org.alfresco.api.AlfrescoPublicApi;
29 import org.codehaus.jackson.annotate.JsonCreator;
30 import org.codehaus.jackson.annotate.JsonProperty;
31
32 /**
33 * Parameters used for search hightlighting.
34 */
35
36 @AlfrescoPublicApi
37 public abstract class HighlightParameters
38 {
39 final Integer snippetCount;
40 final Integer fragmentSize;
41
42 final Boolean mergeContiguous;
43
44 final String prefix;
45 final String postfix;
46
47 public HighlightParameters(Integer snippetCount, Integer fragmentSize,
48 Boolean mergeContiguous, String prefix, String postfix)
49 {
50 this.snippetCount = snippetCount;
51 this.fragmentSize = fragmentSize;
52 this.mergeContiguous = mergeContiguous;
53 this.prefix = prefix;
54 this.postfix = postfix;
55 }
56
57 @Override
58 public boolean equals(Object o)
59 {
60 if (this == o)
61 return true;
62 if (o == null || getClass() != o.getClass())
63 return false;
64
65 HighlightParameters that = (HighlightParameters) o;
66
67 if (snippetCount != null ? !snippetCount.equals(that.snippetCount) : that.snippetCount != null)
68 return false;
69 if (fragmentSize != null ? !fragmentSize.equals(that.fragmentSize) : that.fragmentSize != null)
70 return false;
71 if (mergeContiguous != null ? !mergeContiguous.equals(that.mergeContiguous) : that.mergeContiguous != null)
72 return false;
73 if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null)
74 return false;
75 if (postfix != null ? !postfix.equals(that.postfix) : that.postfix != null)
76 return false;
77
78 return true;
79 }
80
81 @Override
82 public int hashCode()
83 {
84 int result = snippetCount != null ? snippetCount.hashCode() : 0;
85 result = 31 * result + (fragmentSize != null ? fragmentSize.hashCode() : 0);
86 result = 31 * result + (mergeContiguous != null ? mergeContiguous.hashCode() : 0);
87 result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
88 result = 31 * result + (postfix != null ? postfix.hashCode() : 0);
89 return result;
90 }
91
92 @Override
93 public String toString()
94 {
95 return "HighlightParameters{" +
96 "snippetCount=" + snippetCount +
97 ", fragmentSize=" + fragmentSize +
98 ", mergeContiguous=" + mergeContiguous +
99 ", prefix='" + prefix + '\'' +
100 ", postfix='" + postfix + '\'' +
101 '}';
102 }
103
104 public Integer getSnippetCount()
105 {
106 return snippetCount;
107 }
108
109 public Integer getFragmentSize()
110 {
111 return fragmentSize;
112 }
113
114 public Boolean getMergeContiguous()
115 {
116 return mergeContiguous;
117 }
118
119 public String getPrefix()
120 {
121 return prefix;
122 }
123
124 public String getPostfix()
125 {
126 return postfix;
127 }
128 }
1 /* 129
src/main/java/org/alfresco/service/cmr/search/ResultSetSPI.java
1 /* 1 /*
2 * #%L 2 * #%L
3 * Alfresco Data model classes 3 * Alfresco Data model classes
4 * %% 4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited 5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %% 6 * %%
7 * This file is part of the Alfresco software. 7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of 8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is 9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms: 10 * provided under the following open source license terms:
11 * 11 *
12 * Alfresco is free software: you can redistribute it and/or modify 12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by 13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or 14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version. 15 * (at your option) any later version.
16 * 16 *
17 * Alfresco is distributed in the hope that it will be useful, 17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details. 20 * GNU Lesser General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Lesser General Public License 22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. 23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L% 24 * #L%
25 */ 25 */
26 package org.alfresco.service.cmr.search; 26 package org.alfresco.service.cmr.search;
27 27
28 import java.util.List; 28 import java.util.List;
29 import java.util.Map; 29 import java.util.Map;
30 30
31 import org.alfresco.api.AlfrescoPublicApi; 31 import org.alfresco.api.AlfrescoPublicApi;
32 import org.alfresco.service.cmr.repository.ChildAssociationRef; 32 import org.alfresco.service.cmr.repository.ChildAssociationRef;
33 import org.alfresco.service.cmr.repository.NodeRef; 33 import org.alfresco.service.cmr.repository.NodeRef;
34 import org.alfresco.util.Pair; 34 import org.alfresco.util.Pair;
35 35
36 /** 36 /**
37 * This is the common interface for both row (Alfresco node) and column (CMIS style property or function) based results. 37 * This is the common interface for both row (Alfresco node) and column (CMIS style property or function) based results.
38 * The meta-data for the results sets contains the detailed info on what columns are available. For row based result 38 * The meta-data for the results sets contains the detailed info on what columns are available. For row based result
39 * sets there is no selector - all the nodes returned do not have to have a specific type or aspect. For example, an FTS 39 * sets there is no selector - all the nodes returned do not have to have a specific type or aspect. For example, an FTS
40 * search on properties of type d:content has no type constraint implied or otherwise. Searches against properties have 40 * search on properties of type d:content has no type constraint implied or otherwise. Searches against properties have
41 * an implied type, but as there can be more than one property -> more than one type or aspect implied (eg via OR in FTS 41 * an implied type, but as there can be more than one property -> more than one type or aspect implied (eg via OR in FTS
42 * or lucene) they are ignored An iterable result set from a searcher query.<b/> Implementations must implement the 42 * or lucene) they are ignored An iterable result set from a searcher query.<b/> Implementations must implement the
43 * indexes for row lookup as zero-based.<b/> 43 * indexes for row lookup as zero-based.<b/>
44 * 44 *
45 * @author andyh 45 * @author andyh
46 * @param <ROW> 46 * @param <ROW>
47 * @param <MD> 47 * @param <MD>
48 */ 48 */
49 @AlfrescoPublicApi 49 @AlfrescoPublicApi
50 public interface ResultSetSPI<ROW extends ResultSetRow, MD extends ResultSetMetaData> extends Iterable<ROW> // Specific iterator over ResultSetRows 50 public interface ResultSetSPI<ROW extends ResultSetRow, MD extends ResultSetMetaData> extends Iterable<ROW> // Specific iterator over ResultSetRows
51 { 51 {
52 /** 52 /**
53 * Get the number of rows in this result set. This will be less than or equal to the maximum number of rows 53 * Get the number of rows in this result set. This will be less than or equal to the maximum number of rows
54 * requested or the full length of the results set if no restriction on length are specified. If a skip count is 54 * requested or the full length of the results set if no restriction on length are specified. If a skip count is
55 * given, the length represents the number of results after the skip count and does not include the items skipped. 55 * given, the length represents the number of results after the skip count and does not include the items skipped.
56 * 56 *
57 * @return the number of results. -1 means unknown and can be returned for lazy evaluations of permissions when the 57 * @return the number of results. -1 means unknown and can be returned for lazy evaluations of permissions when the
58 * actual size is not known and evaluated upon request. 58 * actual size is not known and evaluated upon request.
59 */ 59 */
60 public int length(); 60 public int length();
61 61
62 /** 62 /**
63 * Attempt to get the number of rows that matched the query. This result set may only contain a section of the results. 63 * Attempt to get the number of rows that matched the query. This result set may only contain a section of the results.
64 * If a skip count is given the number found may or may not include the items skipped. 64 * If a skip count is given the number found may or may not include the items skipped.
65 * This is best effort and only done if is cheap. 65 * This is best effort and only done if is cheap.
66 * For SOLR it is cheap; for the DB it may be expensive as permissions are done post query. 66 * For SOLR it is cheap; for the DB it may be expensive as permissions are done post query.
67 * If you want to know if there are more results to fetch use hasMore() 67 * If you want to know if there are more results to fetch use hasMore()
68 * @return long 68 * @return long
69 */ 69 */
70 public long getNumberFound(); 70 public long getNumberFound();
71 71
72 /** 72 /**
73 * Get the id of the node at the given index (if there is only one selector or no selector) 73 * Get the id of the node at the given index (if there is only one selector or no selector)
74 * 74 *
75 * @param n 75 * @param n
76 * zero-based index 76 * zero-based index
77 * @return return the the node ref for the row if there is only one selector 77 * @return return the the node ref for the row if there is only one selector
78 */ 78 */
79 public NodeRef getNodeRef(int n); 79 public NodeRef getNodeRef(int n);
80 80
81 /** 81 /**
82 * Get the score for the node at the given position (if there is only one selector or no selector) 82 * Get the score for the node at the given position (if there is only one selector or no selector)
83 * 83 *
84 * @param n 84 * @param n
85 * zero-based index 85 * zero-based index
86 * @return return the score for the row if there is only one selector 86 * @return return the score for the row if there is only one selector
87 */ 87 */
88 public float getScore(int n); 88 public float getScore(int n);
89 89
90 /** 90 /**
91 * Close the result set and release any resources held/ The result set is bound to the transaction and will auto 91 * Close the result set and release any resources held/ The result set is bound to the transaction and will auto
92 * close at the end of the transaction. 92 * close at the end of the transaction.
93 */ 93 */
94 public void close(); 94 public void close();
95 95
96 /** 96 /**
97 * Get a row from the result set by row index, starting at 0. 97 * Get a row from the result set by row index, starting at 0.
98 * 98 *
99 * @param i 99 * @param i
100 * zero-based index 100 * zero-based index
101 * @return return the row 101 * @return return the row
102 */ 102 */
103 public ROW getRow(int i); 103 public ROW getRow(int i);
104 104
105 /** 105 /**
106 * Get a list of all the node refs in the result set (if there is only one selector or no selector) 106 * Get a list of all the node refs in the result set (if there is only one selector or no selector)
107 * 107 *
108 * @return the node refs if there is only one selector or no selector * 108 * @return the node refs if there is only one selector or no selector *
109 */ 109 */
110 public List<NodeRef> getNodeRefs(); 110 public List<NodeRef> getNodeRefs();
111 111
112 /** 112 /**
113 * Get a list of all the child associations in the results set. (if there is only one selectoror no selector) 113 * Get a list of all the child associations in the results set. (if there is only one selectoror no selector)
114 * 114 *
115 * @return the child assoc refs if there is only one selector or no selector * 115 * @return the child assoc refs if there is only one selector or no selector *
116 */ 116 */
117 public List<ChildAssociationRef> getChildAssocRefs(); 117 public List<ChildAssociationRef> getChildAssocRefs();
118 118
119 /** 119 /**
120 * Get the child assoc ref for a particular row. (if there is only one selectoror no selector) 120 * Get the child assoc ref for a particular row. (if there is only one selectoror no selector)
121 * 121 *
122 * @param n 122 * @param n
123 * zero-based index 123 * zero-based index
124 * @return the child assoc ref for the row if there is only one selector or no selector 124 * @return the child assoc ref for the row if there is only one selector or no selector
125 */ 125 */
126 public ChildAssociationRef getChildAssocRef(int n); 126 public ChildAssociationRef getChildAssocRef(int n);
127 127
128 /** 128 /**
129 * Get the meta data for the results set. 129 * Get the meta data for the results set.
130 * 130 *
131 * @return the metadata 131 * @return the metadata
132 */ 132 */
133 public MD getResultSetMetaData(); 133 public MD getResultSetMetaData();
134 134
135 /** 135 /**
136 * Get the start point for this results set in the overall set of rows that match the query - this will be equal to 136 * Get the start point for this results set in the overall set of rows that match the query - this will be equal to
137 * the skip count set when executing the query, and zero if this is not set. 137 * the skip count set when executing the query, and zero if this is not set.
138 * 138 *
139 * @return the position of the first result in the overall result set 139 * @return the position of the first result in the overall result set
140 */ 140 */
141 public int getStart(); 141 public int getStart();
142 142
143 /** 143 /**
144 * Was this result set curtailed - are there more pages to the result set? 144 * Was this result set curtailed - are there more pages to the result set?
145 * 145 *
146 * @return true if there are more pages in the result set 146 * @return true if there are more pages in the result set
147 */ 147 */
148 public boolean hasMore(); 148 public boolean hasMore();
149 149
150 /** 150 /**
151 * Bulk fetch results in the cache 151 * Bulk fetch results in the cache
152 * 152 *
153 * @param bulkFetch boolean 153 * @param bulkFetch boolean
154 */ 154 */
155 public boolean setBulkFetch(boolean bulkFetch); 155 public boolean setBulkFetch(boolean bulkFetch);
156 156
157 /** 157 /**
158 * Do we bulk fetch 158 * Do we bulk fetch
159 * 159 *
160 * @return - true if we do 160 * @return - true if we do
161 */ 161 */
162 public boolean getBulkFetch(); 162 public boolean getBulkFetch();
163 163
164 /** 164 /**
165 * Set the bulk fetch size 165 * Set the bulk fetch size
166 * 166 *
167 * @param bulkFetchSize int 167 * @param bulkFetchSize int
168 */ 168 */
169 public int setBulkFetchSize(int bulkFetchSize); 169 public int setBulkFetchSize(int bulkFetchSize);
170 170
171 /** 171 /**
172 * Get the bulk fetch size. 172 * Get the bulk fetch size.
173 * 173 *
174 * @return the fetch size 174 * @return the fetch size
175 */ 175 */
176 public int getBulkFetchSize(); 176 public int getBulkFetchSize();
177 177
178 /** 178 /**
179 * @param field String 179 * @param field String
180 * @return List 180 * @return List
181 */ 181 */
182 public List<Pair<String, Integer>> getFieldFacet(String field); 182 public List<Pair<String, Integer>> getFieldFacet(String field);
183 183
184 /** 184 /**
185 * Gets the facet query results 185 * Gets the facet query results
186 * 186 *
187 * @return Map of {@literal <requested facet query, count>} 187 * @return Map of {@literal <requested facet query, count>}
188 */ 188 */
189 public Map<String, Integer> getFacetQueries(); 189 public Map<String, Integer> getFacetQueries();
190 190
191 /** 191 /**
192 * Gets the highlighting results. Returns a Map keyed by noderef.
193 * Each value is a pair of "fieldname" and a String array of highlight snippets
194 * @return the Map
195 */
196 public Map<NodeRef, List<Pair<String, List<String>>>> getHighlighting();
197 /**
192 * Gets the highlighting results. Returns a Map keyed by noderef. 198 * Gets the spell check result
193 * Each value is a pair of "fieldname" and a String array of highlight snippets 199 *
194 * @return the Map 200 * @return SpellCheckResult
195 */ 201 */
196 public Map<NodeRef, List<Pair<String, List<String>>>> getHighlighting(); 202 public SpellCheckResult getSpellCheckResult();
197 /** 203 }
198 * Gets the spell check result 204
src/main/java/org/alfresco/service/cmr/search/SearchParameters.java
1 /* 1 /*
2 * #%L 2 * #%L
3 * Alfresco Data model classes 3 * Alfresco Data model classes
4 * %% 4 * %%
5 * Copyright (C) 2005 - 2016 Alfresco Software Limited 5 * Copyright (C) 2005 - 2016 Alfresco Software Limited
6 * %% 6 * %%
7 * This file is part of the Alfresco software. 7 * This file is part of the Alfresco software.
8 * If the software was purchased under a paid Alfresco license, the terms of 8 * If the software was purchased under a paid Alfresco license, the terms of
9 * the paid license agreement will prevail. Otherwise, the software is 9 * the paid license agreement will prevail. Otherwise, the software is
10 * provided under the following open source license terms: 10 * provided under the following open source license terms:
11 * 11 *
12 * Alfresco is free software: you can redistribute it and/or modify 12 * Alfresco is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by 13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or 14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version. 15 * (at your option) any later version.
16 * 16 *
17 * Alfresco is distributed in the hope that it will be useful, 17 * Alfresco is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details. 20 * GNU Lesser General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Lesser General Public License 22 * You should have received a copy of the GNU Lesser General Public License
23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. 23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
24 * #L% 24 * #L%
25 */ 25 */
26 package org.alfresco.service.cmr.search; 26 package org.alfresco.service.cmr.search;
27 27
28 import java.util.ArrayList; 28 import java.util.ArrayList;
29 import java.util.Collections; 29 import java.util.Collections;
30 import java.util.HashMap; 30 import java.util.HashMap;
31 import java.util.HashSet; 31 import java.util.HashSet;
32 import java.util.List; 32 import java.util.List;
33 import java.util.Locale; 33 import java.util.Locale;
34 import java.util.Map; 34 import java.util.Map;
35 import java.util.Set; 35 import java.util.Set;
36 36
37 import org.alfresco.api.AlfrescoPublicApi; 37 import org.alfresco.api.AlfrescoPublicApi;
38 import org.alfresco.error.AlfrescoRuntimeException; 38 import org.alfresco.error.AlfrescoRuntimeException;
39 import org.alfresco.repo.search.MLAnalysisMode; 39 import org.alfresco.repo.search.MLAnalysisMode;
40 import org.alfresco.repo.search.impl.querymodel.QueryOptions; 40 import org.alfresco.repo.search.impl.querymodel.QueryOptions;
41 import org.alfresco.service.cmr.repository.StoreRef; 41 import org.alfresco.service.cmr.repository.StoreRef;
42 import org.alfresco.service.namespace.NamespaceService; 42 import org.alfresco.service.namespace.NamespaceService;
43 import org.springframework.extensions.surf.util.I18NUtil; 43 import org.springframework.extensions.surf.util.I18NUtil;
44 44
45 /** 45 /**
46 * This class provides parameters to define a search. TODO - paging of results page number and page size - paging 46 * This class provides parameters to define a search. TODO - paging of results page number and page size - paging
47 * isolation - REPEATABLE READ, READ COMMITTED, may SEE ONCE tracking node refs in previous result sets - how long 47 * isolation - REPEATABLE READ, READ COMMITTED, may SEE ONCE tracking node refs in previous result sets - how long
48 * repeatable read may be held - limit by the number of permission evaluations 48 * repeatable read may be held - limit by the number of permission evaluations
49 * 49 *
50 * @author Andy Hind 50 * @author Andy Hind
51 */ 51 */
52 @AlfrescoPublicApi 52 @AlfrescoPublicApi
53 public class SearchParameters implements BasicSearchParameters 53 public class SearchParameters implements BasicSearchParameters
54 { 54 {
55 /* 55 /*
56 * The default limit if someone asks for a limited result set but does not say how to limit.... 56 * The default limit if someone asks for a limited result set but does not say how to limit....
57 */ 57 */
58 private static int DEFAULT_LIMIT = 500; 58 private static int DEFAULT_LIMIT = 500;
59 59
60 /* 60 /*
61 * Standard sort definitions for sorting in document and score order. 61 * Standard sort definitions for sorting in document and score order.
62 */ 62 */
63 /** 63 /**
64 * Sort in the order docs were added to the index - oldest docs first 64 * Sort in the order docs were added to the index - oldest docs first
65 */ 65 */
66 public static final SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, true); 66 public static final SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, true);
67 67
68 /** 68 /**
69 * Sort in the reverse order docs were added to the index - new/updateed docs first 69 * Sort in the reverse order docs were added to the index - new/updateed docs first
70 */ 70 */
71 public static final SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, false); 71 public static final SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, false);
72 72
73 /** 73 /**
74 * Sort in ascending score 74 * Sort in ascending score
75 */ 75 */
76 public static final SortDefinition SORT_IN_SCORE_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, true); 76 public static final SortDefinition SORT_IN_SCORE_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, true);
77 77
78 /** 78 /**
79 * Sort in descending score order 79 * Sort in descending score order
80 */ 80 */
81 public static final SortDefinition SORT_IN_SCORE_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, false); 81 public static final SortDefinition SORT_IN_SCORE_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, false);
82 82
83 /** 83 /**
84 * An emum defining if the default action is to "and" or "or" unspecified components in the query register. Not all 84 * An emum defining if the default action is to "and" or "or" unspecified components in the query register. Not all
85 * search implementations will support this. 85 * search implementations will support this.
86 */ 86 */
87 public enum Operator 87 public enum Operator
88 { 88 {
89 /** 89 /**
90 * OR 90 * OR
91 */ 91 */
92 OR, 92 OR,
93 /** 93 /**
94 * AND 94 * AND
95 */ 95 */
96 AND 96 AND
97 } 97 }
98 98
99 /* 99 /*
100 * Expose as constants 100 * Expose as constants
101 */ 101 */
102 /** 102 /**
103 * OR 103 * OR
104 */ 104 */
105 public static final Operator OR = Operator.OR; 105 public static final Operator OR = Operator.OR;
106 106
107 /** 107 /**
108 * AND 108 * AND
109 */ 109 */
110 public static final Operator AND = Operator.AND; 110 public static final Operator AND = Operator.AND;
111 111
112 /** 112 /**
113 * A parameter that can be passed to Solr to indicate an alternative dictionary should be used. 113 * A parameter that can be passed to Solr to indicate an alternative dictionary should be used.
114 */ 114 */
115 public static final String ALTERNATIVE_DICTIONARY = "alternativeDic"; 115 public static final String ALTERNATIVE_DICTIONARY = "alternativeDic";
116 116
117 /* 117 /*
118 * The parameters that can be set 118 * The parameters that can be set
119 */ 119 */
120 private String language; 120 private String language;
121 121
122 private String query; 122 private String query;
123 123
124 private ArrayList<StoreRef> stores = new ArrayList<StoreRef>(1); 124 private ArrayList<StoreRef> stores = new ArrayList<StoreRef>(1);
125 125
126 private ArrayList<QueryParameterDefinition> queryParameterDefinitions = new ArrayList<QueryParameterDefinition>(1); 126 private ArrayList<QueryParameterDefinition> queryParameterDefinitions = new ArrayList<QueryParameterDefinition>(1);
127 127
128 private boolean excludeDataInTheCurrentTransaction = false; 128 private boolean excludeDataInTheCurrentTransaction = false;
129 129
130 private ArrayList<SortDefinition> sortDefinitions = new ArrayList<SortDefinition>(1); 130 private ArrayList<SortDefinition> sortDefinitions = new ArrayList<SortDefinition>(1);
131 131
132 private ArrayList<Locale> locales = new ArrayList<Locale>(); 132 private ArrayList<Locale> locales = new ArrayList<Locale>();
133 133
134 private MLAnalysisMode mlAnalaysisMode = null; // Pick up from config if null 134 private MLAnalysisMode mlAnalaysisMode = null; // Pick up from config if null
135 135
136 private LimitBy limitBy = LimitBy.UNLIMITED; 136 private LimitBy limitBy = LimitBy.UNLIMITED;
137 137
138 private PermissionEvaluationMode permissionEvaluation = PermissionEvaluationMode.EAGER; 138 private PermissionEvaluationMode permissionEvaluation = PermissionEvaluationMode.EAGER;
139 139
140 private int limit = DEFAULT_LIMIT; 140 private int limit = DEFAULT_LIMIT;
141 141
142 private HashSet<String> allAttributes = new HashSet<String>(); 142 private HashSet<String> allAttributes = new HashSet<String>();
143 143
144 private HashSet<String> textAttributes = new HashSet<String>(); 144 private HashSet<String> textAttributes = new HashSet<String>();
145 145
146 private int maxItems = -1; 146 private int maxItems = -1;
147 147
148 private int skipCount = 0; 148 private int skipCount = 0;
149 149
150 private Operator defaultFTSOperator = Operator.OR; 150 private Operator defaultFTSOperator = Operator.OR;
151 151
152 private Operator defaultFTSFieldOperator = Operator.OR; 152 private Operator defaultFTSFieldOperator = Operator.OR;
153 153
154 private Map<String, String> queryTemplates = new HashMap<String, String>(); 154 private Map<String, String> queryTemplates = new HashMap<String, String>();
155 155
156 private String namespace = NamespaceService.CONTENT_MODEL_1_0_URI; 156 private String namespace = NamespaceService.CONTENT_MODEL_1_0_URI;
157 157
158 // By default uses the central config 158 // By default uses the central config
159 private int maxPermissionChecks = -1; 159 private int maxPermissionChecks = -1;
160 160
161 // By default uses the central config 161 // By default uses the central config
162 private long maxPermissionCheckTimeMillis = -1; 162 private long maxPermissionCheckTimeMillis = -1;
163 163
164 private String defaultFieldName = "TEXT"; 164 private String defaultFieldName = "TEXT";
165 165
166 private ArrayList<FieldFacet> fieldFacets = new ArrayList<FieldFacet>(); 166 private ArrayList<FieldFacet> fieldFacets = new ArrayList<FieldFacet>();
167 167
168 private List<String> facetQueries = new ArrayList<String>(); 168 private List<String> facetQueries = new ArrayList<String>();
169 169
170 private List<String> filterQueries = new ArrayList<String>(); 170 private List<String> filterQueries = new ArrayList<String>();
171 171
172 private Boolean useInMemorySort; 172 private Boolean useInMemorySort;
173 173
174 private Integer maxRawResultSetSizeForInMemorySort; 174 private Integer maxRawResultSetSizeForInMemorySort;
175 175
176 private Map<String, String> extraParameters = new HashMap<String, String>(); 176 private Map<String, String> extraParameters = new HashMap<String, String>();
177 177
178 private boolean excludeTenantFilter = false; 178 private boolean excludeTenantFilter = false;
179 179
180 private boolean isBulkFetchEnabled = true; 180 private boolean isBulkFetchEnabled = true;
181 181
182 private QueryConsistency queryConsistency = QueryConsistency.DEFAULT; 182 private QueryConsistency queryConsistency = QueryConsistency.DEFAULT;
183 183
184 private Long sinceTxId; 184 private Long sinceTxId;
185 185
186 private String searchTerm; 186 private String searchTerm;
187 187
188 private boolean spellCheck; 188 private boolean spellCheck;
189 189
190 private GeneralHighlightParameters hightlight;
191
190 private GeneralHighlightParameters hightlight; 192 /**
191 193 * Default constructor
192 /** 194 */
193 * Default constructor 195 public SearchParameters()
194 */ 196 {
195 public SearchParameters() 197 super();
196 { 198 }
197 super(); 199
198 } 200 public SearchParameters copy()
199 201 {
200 public SearchParameters copy() 202 SearchParameters sp = new SearchParameters();
201 { 203 sp.allAttributes.addAll(this.allAttributes);
202 SearchParameters sp = new SearchParameters(); 204 sp.defaultFieldName = this.defaultFieldName;
203 sp.allAttributes.addAll(this.allAttributes); 205 sp.defaultFTSFieldOperator = this.defaultFTSFieldOperator;
204 sp.defaultFieldName = this.defaultFieldName; 206 sp.defaultFTSOperator = this.defaultFTSOperator;
205 sp.defaultFTSFieldOperator = this.defaultFTSFieldOperator; 207 sp.excludeDataInTheCurrentTransaction = this.excludeDataInTheCurrentTransaction;
206 sp.defaultFTSOperator = this.defaultFTSOperator; 208 sp.fieldFacets.addAll(this.fieldFacets);
207 sp.excludeDataInTheCurrentTransaction = this.excludeDataInTheCurrentTransaction; 209 sp.language = this.language;
208 sp.fieldFacets.addAll(this.fieldFacets); 210 sp.limit = this.limit;
209 sp.language = this.language; 211 sp.limitBy = this.limitBy;
210 sp.limit = this.limit; 212 sp.locales.addAll(this.locales);
211 sp.limitBy = this.limitBy; 213 sp.maxItems = this.maxItems;
212 sp.locales.addAll(this.locales); 214 sp.maxPermissionChecks = this.maxPermissionChecks;
213 sp.maxItems = this.maxItems; 215 sp.maxPermissionCheckTimeMillis = this.maxPermissionCheckTimeMillis;
214 sp.maxPermissionChecks = this.maxPermissionChecks; 216 sp.mlAnalaysisMode = this.mlAnalaysisMode;
215 sp.maxPermissionCheckTimeMillis = this.maxPermissionCheckTimeMillis; 217 sp.namespace = this.namespace;
216 sp.mlAnalaysisMode = this.mlAnalaysisMode; 218 sp.permissionEvaluation = this.permissionEvaluation;
217 sp.namespace = this.namespace; 219 sp.query = this.query;
218 sp.permissionEvaluation = this.permissionEvaluation; 220 sp.queryParameterDefinitions.addAll(this.queryParameterDefinitions);
219 sp.query = this.query; 221 sp.queryTemplates.putAll(this.queryTemplates);
220 sp.queryParameterDefinitions.addAll(this.queryParameterDefinitions); 222 sp.skipCount = this.skipCount;
221 sp.queryTemplates.putAll(this.queryTemplates); 223 sp.sortDefinitions.addAll(this.sortDefinitions);
222 sp.skipCount = this.skipCount; 224 sp.stores.addAll(this.stores);
223 sp.sortDefinitions.addAll(this.sortDefinitions); 225 sp.textAttributes.addAll(this.textAttributes);
224 sp.stores.addAll(this.stores); 226 sp.useInMemorySort = this.useInMemorySort;
225 sp.textAttributes.addAll(this.textAttributes); 227 sp.maxRawResultSetSizeForInMemorySort = this.maxRawResultSetSizeForInMemorySort;
226 sp.useInMemorySort = this.useInMemorySort; 228 sp.isBulkFetchEnabled = this.isBulkFetchEnabled;
227 sp.maxRawResultSetSizeForInMemorySort = this.maxRawResultSetSizeForInMemorySort; 229 sp.excludeTenantFilter = this.excludeTenantFilter;
228 sp.isBulkFetchEnabled = this.isBulkFetchEnabled; 230 sp.queryConsistency = this.queryConsistency;
229 sp.excludeTenantFilter = this.excludeTenantFilter; 231 sp.sinceTxId = this.sinceTxId;
230 sp.queryConsistency = this.queryConsistency; 232 sp.facetQueries.addAll(this.facetQueries);
231 sp.sinceTxId = this.sinceTxId; 233 sp.filterQueries.addAll(this.filterQueries);
232 sp.facetQueries.addAll(this.facetQueries); 234 sp.searchTerm = this.searchTerm;
233 sp.filterQueries.addAll(this.filterQueries); 235 sp.spellCheck = this.spellCheck;
236 sp.hightlight = this.hightlight;
234 sp.searchTerm = this.searchTerm; 237 return sp;
235 sp.spellCheck = this.spellCheck; 238 }
236 sp.hightlight = this.hightlight; 239
237 return sp; 240 /**
238 } 241 * Construct from Query Options
239 242 *
240 /** 243 * @param options QueryOptions
241 * Construct from Query Options 244 */
242 * 245 public SearchParameters(QueryOptions options)
243 * @param options QueryOptions 246 {
244 */ 247 setSkipCount(options.getSkipCount());
245 public SearchParameters(QueryOptions options) 248 setMaxPermissionChecks(options.getMaxPermissionChecks());
246 { 249 setMaxPermissionCheckTimeMillis(options.getMaxPermissionCheckTimeMillis());
247 setSkipCount(options.getSkipCount()); 250 setBulkFetchEnabled(options.isBulkFetchEnabled());
248 setMaxPermissionChecks(options.getMaxPermissionChecks()); 251 if (options.getMaxItems() >= 0)
249 setMaxPermissionCheckTimeMillis(options.getMaxPermissionCheckTimeMillis()); 252 {
250 setBulkFetchEnabled(options.isBulkFetchEnabled()); 253 setLimitBy(LimitBy.FINAL_SIZE);
251 if (options.getMaxItems() >= 0) 254 setLimit(options.getMaxItems());
252 { 255 setMaxItems(options.getMaxItems());
253 setLimitBy(LimitBy.FINAL_SIZE); 256 }
254 setLimit(options.getMaxItems()); 257 else
255 setMaxItems(options.getMaxItems()); 258 {
256 } 259 setLimitBy(LimitBy.UNLIMITED);
257 else 260 }
258 { 261 }
259 setLimitBy(LimitBy.UNLIMITED); 262
260 } 263 /**
261 } 264 * Get the search language
262 265 *
263 /** 266 * @return - string id of search language
264 * Get the search language 267 */
265 * 268 public String getLanguage()
266 * @return - string id of search language 269 {
267 */ 270 return language;
268 public String getLanguage() 271 }
269 { 272
270 return language; 273 /**
271 } 274 * Get the query.
272 275 *
273 /** 276 * @return - the query string
274 * Get the query. 277 */
275 * 278 public String getQuery()
276 * @return - the query string 279 {
277 */ 280 return query;
278 public String getQuery() 281 }
279 { 282
283 public void setHightlight(GeneralHighlightParameters hightlight)
284 {
285 this.hightlight = hightlight;
286 }
287
280 return query; 288 /**
281 } 289 * Set the query language.
282 290 *
283 public void setHightlight(GeneralHighlightParameters hightlight) 291 * @param language -
284 { 292 * the query language.
285 this.hightlight = hightlight; 293 */
286 } 294 public void setLanguage(String language)
287 295 {
288 /** 296 this.language = language;
289 * Set the query language. 297 }
290 * 298
291 * @param language - 299 public void addExtraParameter(String name, String value)
292 * the query language. 300 {
293 */ 301 extraParameters.put(name, value);
294 public void setLanguage(String language) 302 }
295 { 303
296 this.language = language; 304 public Map<String, String> getExtraParameters()
297 } 305 {
298 306 return extraParameters;
299 public void addExtraParameter(String name, String value) 307 }
300 { 308
301 extraParameters.put(name, value); 309 /**
302 } 310 * Set the query string.
303 311 *
304 public Map<String, String> getExtraParameters() 312 * @param query -
305 { 313 * the query string.
306 return extraParameters; 314 */
307 } 315 public void setQuery(String query)
308 316 {
309 /** 317 this.query = query;
310 * Set the query string. 318 }
311 * 319
312 * @param query - 320 /**
313 * the query string. 321 * Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo
314 */ 322 * list.
315 public void setQuery(String query) 323 *
316 { 324 * @param store StoreRef
317 this.query = query; 325 */
318 } 326 public void addStore(StoreRef store)
319 327 {
320 /** 328 stores.add(store);
321 * Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo 329 }
322 * list. 330
323 * 331 /**
324 * @param store StoreRef 332 * Add parameter definitions for the query - used to parameterise the query string
325 */ 333 *
326 public void addStore(StoreRef store) 334 * @param queryParameterDefinition QueryParameterDefinition
327 { 335 */
328 stores.add(store); 336 public void addQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition)
329 } 337 {
330 338 queryParameterDefinitions.add(queryParameterDefinition);
331 /** 339 }
332 * Add parameter definitions for the query - used to parameterise the query string 340
333 * 341 /**
334 * @param queryParameterDefinition QueryParameterDefinition 342 * If true, any data in the current transaction will be ignored in the search. You will not see anything you have
335 */ 343 * added in the current transaction. By default you will see data in the current transaction. This effectively gives
336 public void addQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition) 344 * read committed isolation. There is a performance overhead for this, at least when using lucene. This flag may be
337 { 345 * set to avoid that performance hit if you know you do not want to find results that are yet to be committed (this
338 queryParameterDefinitions.add(queryParameterDefinition); 346 * includes creations, deletions and updates)
339 } 347 *
340 348 * @param excludeDataInTheCurrentTransaction boolean
341 /** 349 */
342 * If true, any data in the current transaction will be ignored in the search. You will not see anything you have 350 public void excludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction)
343 * added in the current transaction. By default you will see data in the current transaction. This effectively gives 351 {
344 * read committed isolation. There is a performance overhead for this, at least when using lucene. This flag may be 352 this.excludeDataInTheCurrentTransaction = excludeDataInTheCurrentTransaction;
345 * set to avoid that performance hit if you know you do not want to find results that are yet to be committed (this 353 }
346 * includes creations, deletions and updates) 354
347 * 355 /**
348 * @param excludeDataInTheCurrentTransaction boolean 356 * Add a sort to the query (for those query languages that do not support it directly) The first sort added is
349 */ 357 * treated as primary, the second as secondary etc. A helper method to create SortDefinitions.
350 public void excludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction) 358 *
351 { 359 * @param field -
352 this.excludeDataInTheCurrentTransaction = excludeDataInTheCurrentTransaction; 360 * this is initially a direct attribute on a node not an attribute on the parent etc TODO: It could be a
353 } 361 * relative path at some time.
354 362 * @param ascending -
355 /** 363 * true to sort ascending, false for descending.
356 * Add a sort to the query (for those query languages that do not support it directly) The first sort added is 364 */
357 * treated as primary, the second as secondary etc. A helper method to create SortDefinitions. 365 public void addSort(String field, boolean ascending)
358 * 366 {
359 * @param field - 367 addSort(new SortDefinition(SortDefinition.SortType.FIELD, field, ascending));
360 * this is initially a direct attribute on a node not an attribute on the parent etc TODO: It could be a 368 }
361 * relative path at some time. 369
362 * @param ascending - 370 /**
363 * true to sort ascending, false for descending. 371 * Add a sort definition.
364 */ 372 *
365 public void addSort(String field, boolean ascending) 373 * @param sortDefinition -
366 { 374 * the sort definition to add. Use the static member variables for sorting in score and index order.
367 addSort(new SortDefinition(SortDefinition.SortType.FIELD, field, ascending)); 375 */
368 } 376 public void addSort(SortDefinition sortDefinition)
369 377 {
370 /** 378 sortDefinitions.add(sortDefinition);
371 * Add a sort definition. 379 }
372 * 380
373 * @param sortDefinition - 381 /**
382 * Adds parameters used for search highlighing
383 * @param hightlight - the highlighting parameters
384 */
385 public void addHightlight(GeneralHighlightParameters hightlight)
386 {
387 this.hightlight = hightlight;
388 }
389
390 /**
391 * Gets the parameters used for search highlighing
392 * @return GeneralHighlightParameters - the highlighting parameters
393 */
394 public GeneralHighlightParameters getHightlight()
395 {
396 return hightlight;
397 }
398
399 /**
374 * the sort definition to add. Use the static member variables for sorting in score and index order. 400 * Is data in the current transaction excluded from the search.
375 */ 401 *
376 public void addSort(SortDefinition sortDefinition) 402 * @return - true if data in the current transaction is ignored
377 { 403 */
378 sortDefinitions.add(sortDefinition); 404 public boolean excludeDataInTheCurrentTransaction()
379 } 405 {
380 406 return excludeDataInTheCurrentTransaction;
381 /** 407 }
382 * Adds parameters used for search highlighing 408
383 * @param hightlight - the highlighting parameters 409 /**
384 */ 410 * Get the query parameters that apply to this query.
385 public void addHightlight(GeneralHighlightParameters hightlight) 411 *
386 { 412 * @return - the parameter
387 this.hightlight = hightlight; 413 */
388 } 414 public ArrayList<QueryParameterDefinition> getQueryParameterDefinitions()
389 415 {
390 /** 416 return queryParameterDefinitions;
391 * Gets the parameters used for search highlighing 417 }
392 * @return GeneralHighlightParameters - the highlighting parameters 418
393 */ 419 /**
394 public GeneralHighlightParameters getHightlight() 420 * Get the sort definitions that apply to this query.
395 { 421 *
396 return hightlight; 422 * @return - the sort definitions
397 } 423 */
398 424 public ArrayList<SortDefinition> getSortDefinitions()
399 /** 425 {
400 * Is data in the current transaction excluded from the search. 426 return sortDefinitions;
401 * 427 }
402 * @return - true if data in the current transaction is ignored 428
403 */ 429 /**
404 public boolean excludeDataInTheCurrentTransaction() 430 * Get the stores in which this query should find results.
405 { 431 *
406 return excludeDataInTheCurrentTransaction; 432 * @return - the list of stores
407 } 433 */
408 434 public ArrayList<StoreRef> getStores()
409 /** 435 {
410 * Get the query parameters that apply to this query. 436 return stores;
411 * 437 }
412 * @return - the parameter 438
413 */ 439 /**
414 public ArrayList<QueryParameterDefinition> getQueryParameterDefinitions() 440 * Set the default operator for query elements when they are not explicit in the query.
415 { 441 *
416 return queryParameterDefinitions; 442 * @param defaultOperator Operator
417 } 443 */
418 444 public void setDefaultOperator(Operator defaultOperator)
419 /** 445 {
420 * Get the sort definitions that apply to this query. 446 this.defaultFTSOperator = defaultOperator;
421 * 447 this.defaultFTSFieldOperator = defaultOperator;
422 * @return - the sort definitions 448 }
423 */ 449
424 public ArrayList<SortDefinition> getSortDefinitions() 450 /**
425 { 451 * Get the default operator for query elements when they are not explicit in the query.
426 return sortDefinitions; 452 *
427 } 453 * @return the default operator
428 454 */
429 /** 455 public Operator getDefaultOperator()
430 * Get the stores in which this query should find results. 456 {
431 * 457 return getDefaultFTSOperator();
432 * @return - the list of stores 458 }
433 */ 459
434 public ArrayList<StoreRef> getStores() 460 /**
435 { 461 * Get how the result set should be limited
436 return stores; 462 *
437 } 463 * @return how the result set will be or was limited
438 464 */
439 /** 465 public LimitBy getLimitBy()
440 * Set the default operator for query elements when they are not explicit in the query. 466 {
441 * 467 return limitBy;
442 * @param defaultOperator Operator 468 }
443 */ 469
444 public void setDefaultOperator(Operator defaultOperator) 470 /**
445 { 471 * Set how the result set should be limited.
446 this.defaultFTSOperator = defaultOperator; 472 *
447 this.defaultFTSFieldOperator = defaultOperator; 473 * @param limitBy LimitBy
448 } 474 */
449 475 public void setLimitBy(LimitBy limitBy)
450 /** 476 {
451 * Get the default operator for query elements when they are not explicit in the query. 477 this.limitBy = limitBy;
452 * 478 }
453 * @return the default operator 479
454 */ 480 /**
455 public Operator getDefaultOperator() 481 * Get when permissions are evaluated.
456 { 482 *
457 return getDefaultFTSOperator(); 483 * @return - how permissions are evaluated
458 } 484 */
459 485 public PermissionEvaluationMode getPermissionEvaluation()
460 /** 486 {
461 * Get how the result set should be limited 487 return permissionEvaluation;
462 * 488 }
463 * @return how the result set will be or was limited 489
464 */ 490 /**
465 public LimitBy getLimitBy() 491 * Set when permissions are evaluated.
466 { 492 *
467 return limitBy; 493 * @param permissionEvaluation PermissionEvaluationMode
468 } 494 */
469 495 public void setPermissionEvaluation(PermissionEvaluationMode permissionEvaluation)
470 /** 496 {
471 * Set how the result set should be limited. 497 this.permissionEvaluation = permissionEvaluation;
472 * 498 }
473 * @param limitBy LimitBy 499
474 */ 500 /**
475 public void setLimitBy(LimitBy limitBy) 501 * If limiting the result set in some way, get the limiting value used.
476 { 502 *
477 this.limitBy = limitBy; 503 * @return the limit
478 } 504 */
479 505 public int getLimit()
480 /** 506 {
481 * Get when permissions are evaluated. 507 return limit;
482 * 508 }
483 * @return - how permissions are evaluated 509
484 */ 510 /**
485 public PermissionEvaluationMode getPermissionEvaluation() 511 * If limiting the result set in some way, set the limiting value used.
486 { 512 *
487 return permissionEvaluation; 513 * @param limit int
488 } 514 */
489 515 public void setLimit(int limit)
490 /** 516 {
491 * Set when permissions are evaluated. 517 this.limit = limit;
492 * 518 }
493 * @param permissionEvaluation PermissionEvaluationMode 519
494 */ 520 /**
495 public void setPermissionEvaluation(PermissionEvaluationMode permissionEvaluation) 521 * The way in which multilingual fields are treated durig a search. By default, only the specified locale is used
496 { 522 * and it must be an exact match.
497 this.permissionEvaluation = permissionEvaluation; 523 *
498 } 524 * @return - how locale related text is tokenised
499 525 */
500 /** 526 public MLAnalysisMode getMlAnalaysisMode()
501 * If limiting the result set in some way, get the limiting value used. 527 {
502 * 528 return mlAnalaysisMode;
503 * @return the limit 529 }
504 */ 530
505 public int getLimit() 531 /**
506 { 532 * Set the way in which multilingual fields are treated durig a search. This controls in which locales an
507 return limit; 533 * multilingual fields will match.
508 } 534 *
509 535 * @param mlAnalaysisMode MLAnalysisMode
510 /** 536 */
511 * If limiting the result set in some way, set the limiting value used. 537 public void setMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode)
512 * 538 {
513 * @param limit int 539 this.mlAnalaysisMode = mlAnalaysisMode;
514 */ 540 }
515 public void setLimit(int limit) 541
516 { 542 /**
517 this.limit = limit; 543 * Add a locale to include for multi-lingual text searches. If non are set, the default is to use the user's locale.
518 } 544 *
519 545 * @param locale Locale
520 /** 546 */
521 * The way in which multilingual fields are treated durig a search. By default, only the specified locale is used 547 public void addLocale(Locale locale)
522 * and it must be an exact match. 548 {
523 * 549 locales.add(locale);
524 * @return - how locale related text is tokenised 550 }
525 */ 551
526 public MLAnalysisMode getMlAnalaysisMode() 552 /**
527 { 553 * Get the locales used for multi-lingual text searches.
528 return mlAnalaysisMode; 554 *
529 } 555 * @return - the locales
530 556 */
531 /** 557 public List<Locale> getLocales()
532 * Set the way in which multilingual fields are treated durig a search. This controls in which locales an 558 {
533 * multilingual fields will match. 559 return Collections.unmodifiableList(locales);
534 * 560 }
535 * @param mlAnalaysisMode MLAnalysisMode 561
536 */ 562 /**
537 public void setMlAnalaysisMode(MLAnalysisMode mlAnalaysisMode) 563 * Add a field for TEXT expansion
538 { 564 *
539 this.mlAnalaysisMode = mlAnalaysisMode; 565 * @param attribute -
540 } 566 * field/attribute in the index
541 567 */
542 /** 568 public void addTextAttribute(String attribute)
543 * Add a locale to include for multi-lingual text searches. If non are set, the default is to use the user's locale. 569 {
544 * 570 textAttributes.add(attribute);
545 * @param locale Locale 571 }
546 */ 572
547 public void addLocale(Locale locale) 573 /**
548 { 574 * Get the text attributes used for text expansion.
549 locales.add(locale); 575 *
550 } 576 * @return the text attributes used for text expansion
551 577 */
552 /** 578 public Set<String> getTextAttributes()
553 * Get the locales used for multi-lingual text searches. 579 {
554 * 580 return Collections.unmodifiableSet(textAttributes);
555 * @return - the locales 581 }
556 */ 582
557 public List<Locale> getLocales() 583 /**
558 { 584 * Add a field for ALL expansion
559 return Collections.unmodifiableList(locales); 585 *
560 } 586 * @param attribute -
561 587 * field/attribute in the index
562 /** 588 */
563 * Add a field for TEXT expansion 589 public void addAllAttribute(String attribute)
564 * 590 {
565 * @param attribute - 591 allAttributes.add(attribute);
566 * field/attribute in the index 592 }
567 */ 593
568 public void addTextAttribute(String attribute) 594 /**
569 { 595 * Get the text attributes used for ALL expansion.
570 textAttributes.add(attribute); 596 *
571 } 597 * @return the text attributes used for ALL expansion
572 598 */
573 /** 599 public Set<String> getAllAttributes()
574 * Get the text attributes used for text expansion. 600 {
575 * 601 return Collections.unmodifiableSet(allAttributes);
576 * @return the text attributes used for text expansion 602 }
577 */ 603
578 public Set<String> getTextAttributes() 604 /**
579 { 605 * Get the max number of rows for the result set 0 or less is unlimited
580 return Collections.unmodifiableSet(textAttributes); 606 *
581 } 607 * @return the maxItems
582 608 */
583 /** 609 public int getMaxItems()
584 * Add a field for ALL expansion 610 {
585 * 611 return maxItems;
586 * @param attribute - 612 }
587 * field/attribute in the index 613
588 */ 614 /**
589 public void addAllAttribute(String attribute) 615 * Set the max number of rows for the result set.
590 { 616 * A negative value implies unlimited
591 allAttributes.add(attribute); 617 * 0 will return no results.
592 } 618 *
593 619 * @param maxItems
594 /** 620 * the maxItems to set
595 * Get the text attributes used for ALL expansion. 621 */
596 * 622 public void setMaxItems(int maxItems)
597 * @return the text attributes used for ALL expansion 623 {
598 */ 624 this.maxItems = maxItems;
599 public Set<String> getAllAttributes() 625 }
600 { 626
601 return Collections.unmodifiableSet(allAttributes); 627 /**
602 } 628 * Get the skip count - the number of rows to skip at the start of the query.
603 629 *
604 /** 630 * @return the skipCount
605 * Get the max number of rows for the result set 0 or less is unlimited 631 */
606 * 632 public int getSkipCount()
607 * @return the maxItems 633 {
608 */ 634 return skipCount;
609 public int getMaxItems() 635 }
610 { 636
611 return maxItems; 637 /**
612 } 638 * Set the skip count - the number of rows to skip at the start of the query.
613 639 *
614 /** 640 * @param skipCount
615 * Set the max number of rows for the result set. 641 * the skipCount to set
616 * A negative value implies unlimited 642 */
617 * 0 will return no results. 643 public void setSkipCount(int skipCount)
618 * 644 {
619 * @param maxItems 645 this.skipCount = skipCount;
620 * the maxItems to set 646 }
621 */ 647
622 public void setMaxItems(int maxItems) 648 /**
623 { 649 * Get the default connective used when OR and AND are not specified for the FTS contains() function.
624 this.maxItems = maxItems; 650 *
625 } 651 * @return the defaultFTSConnective
626 652 */
627 /** 653 public Operator getDefaultFTSOperator()
628 * Get the skip count - the number of rows to skip at the start of the query. 654 {
629 * 655 return defaultFTSOperator;
630 * @return the skipCount 656 }
631 */ 657
632 public int getSkipCount() 658 /**
633 { 659 * Set the default connective used when OR and AND are not specified for the FTS contains() function.
634 return skipCount; 660 *
635 } 661 * @param defaultFTSOperator
636 662 * the defaultFTSOperator to set
637 /** 663 */
638 * Set the skip count - the number of rows to skip at the start of the query. 664 public void setDefaultFTSOperator(Operator defaultFTSOperator)
639 * 665 {
640 * @param skipCount 666 this.defaultFTSOperator = defaultFTSOperator;
641 * the skipCount to set 667 }
642 */ 668
643 public void setSkipCount(int skipCount) 669 /**
644 { 670 * As getDefaultFTSConnective() but for field groups
645 this.skipCount = skipCount; 671 *
646 } 672 * @return the defaultFTSFieldConnective
647 673 */
648 /** 674 public Operator getDefaultFTSFieldOperator()
649 * Get the default connective used when OR and AND are not specified for the FTS contains() function. 675 {
650 * 676 return defaultFTSFieldOperator;
651 * @return the defaultFTSConnective 677 }
652 */ 678
653 public Operator getDefaultFTSOperator() 679 /**
654 { 680 * As setDefaultFTSConnective() but for field groups
655 return defaultFTSOperator; 681 *
656 } 682 * @param defaultFTSFieldOperator
657 683 * the defaultFTSFieldOperator to set
658 /** 684 */
659 * Set the default connective used when OR and AND are not specified for the FTS contains() function. 685 public void setDefaultFTSFieldConnective(Operator defaultFTSFieldOperator)
660 * 686 {
661 * @param defaultFTSOperator 687 this.defaultFTSFieldOperator = defaultFTSFieldOperator;
662 * the defaultFTSOperator to set 688 }
663 */ 689
664 public void setDefaultFTSOperator(Operator defaultFTSOperator) 690 /**
665 { 691 * Get the default namespace.
666 this.defaultFTSOperator = defaultFTSOperator; 692 *
667 } 693 * @return the default namspace uri or prefix.
668 694 */
669 /** 695 public String getNamespace()
670 * As getDefaultFTSConnective() but for field groups 696 {
671 * 697 return namespace;
672 * @return the defaultFTSFieldConnective 698 }
673 */ 699
674 public Operator getDefaultFTSFieldOperator() 700 /**
675 { 701 * Set the default namespace
676 return defaultFTSFieldOperator; 702 *
677 } 703 * @param namespace -
678 704 * the uri or prefix for the default namespace.
679 /** 705 */
680 * As setDefaultFTSConnective() but for field groups 706 public void setNamespace(String namespace)
681 * 707 {
682 * @param defaultFTSFieldOperator 708 this.namespace = namespace;
683 * the defaultFTSFieldOperator to set 709 }
684 */ 710
685 public void setDefaultFTSFieldConnective(Operator defaultFTSFieldOperator) 711 /**
686 { 712 * Get the query templates
687 this.defaultFTSFieldOperator = defaultFTSFieldOperator; 713 *
688 } 714 * @return - the query templates
689 715 */
690 /** 716 public Map<String, String> getQueryTemplates()
691 * Get the default namespace. 717 {
692 * 718 return queryTemplates;
693 * @return the default namspace uri or prefix. 719 }
694 */ 720
695 public String getNamespace() 721 /**
696 { 722 * Add/replace a query template Not all languages support query templates
697 return namespace; 723 *
698 } 724 * @param name String
699 725 * @param template String
700 /** 726 * @return any removed template or null
701 * Set the default namespace 727 */
702 * 728 public String addQueryTemplate(String name, String template)
703 * @param namespace - 729 {
704 * the uri or prefix for the default namespace. 730 return queryTemplates.put(name, template);
705 */ 731 }
706 public void setNamespace(String namespace) 732
707 { 733 public long getMaxPermissionCheckTimeMillis()
708 this.namespace = namespace; 734 {
709 } 735 return maxPermissionCheckTimeMillis;
710 736 }
711 /** 737
712 * Get the query templates 738 public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)
713 * 739 {
714 * @return - the query templates 740 this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis;
715 */ 741 }
716 public Map<String, String> getQueryTemplates() 742
717 { 743 public int getMaxPermissionChecks()
718 return queryTemplates; 744 {
719 } 745 return maxPermissionChecks;
720 746 }
721 /** 747
722 * Add/replace a query template Not all languages support query templates 748 public void setMaxPermissionChecks(int maxPermissionChecks)
723 * 749 {
724 * @param name String 750 this.maxPermissionChecks = maxPermissionChecks;
725 * @param template String 751 }
726 * @return any removed template or null 752
727 */ 753 /**
728 public String addQueryTemplate(String name, String template) 754 * @return the useInMemorySort
729 { 755 */
730 return queryTemplates.put(name, template); 756 public Boolean getUseInMemorySort()
731 } 757 {
732 758 return useInMemorySort;
733 public long getMaxPermissionCheckTimeMillis() 759 }
734 { 760
735 return maxPermissionCheckTimeMillis; 761 /**
736 } 762 * @param useInMemorySort the useInMemorySort to set
737 763 */
738 public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis) 764 public void setUseInMemorySort(Boolean useInMemorySort)
739 { 765 {
740 this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis; 766 this.useInMemorySort = useInMemorySort;
741 } 767 }
742 768
743 public int getMaxPermissionChecks() 769 /**
744 { 770 * @return the maxRawResultSetSizeForInMemorySort
745 return maxPermissionChecks; 771 */
746 } 772 public Integer getMaxRawResultSetSizeForInMemorySort()
747 773 {
748 public void setMaxPermissionChecks(int maxPermissionChecks) 774 return maxRawResultSetSizeForInMemorySort;
749 { 775 }
750 this.maxPermissionChecks = maxPermissionChecks; 776
751 } 777 /**
752 778 * @param maxRawResultSetSizeForInMemorySort the maxRawResultSetSizeForInMemorySort to set
753 /** 779 */
754 * @return the useInMemorySort 780 public void setMaxRawResultSetSizeForInMemorySort(Integer maxRawResultSetSizeForInMemorySort)
755 */ 781 {
756 public Boolean getUseInMemorySort() 782 this.maxRawResultSetSizeForInMemorySort = maxRawResultSetSizeForInMemorySort;
757 { 783 }
758 return useInMemorySort; 784
759 } 785 /**
760 786 * @return true if bulk fetch is enabled
761 /** 787 */
762 * @param useInMemorySort the useInMemorySort to set 788 public boolean isBulkFetchEnabled()
763 */ 789 {
764 public void setUseInMemorySort(Boolean useInMemorySort) 790 return isBulkFetchEnabled;
765 { 791 }
766 this.useInMemorySort = useInMemorySort; 792
767 } 793 /**
768 794 * @param isBulkFetchEnabled boolean
769 /** 795 */
770 * @return the maxRawResultSetSizeForInMemorySort 796 public void setBulkFetchEnabled(boolean isBulkFetchEnabled)
771 */ 797 {
772 public Integer getMaxRawResultSetSizeForInMemorySort() 798 this.isBulkFetchEnabled = isBulkFetchEnabled;
773 { 799 }
774 return maxRawResultSetSizeForInMemorySort; 800
775 } 801
776 802 /**
777 /** 803 * A helper class for sort definition. Encapsulated using the lucene sortType, field name and a flag for
778 * @param maxRawResultSetSizeForInMemorySort the maxRawResultSetSizeForInMemorySort to set 804 * ascending/descending.
779 */ 805 *
780 public void setMaxRawResultSetSizeForInMemorySort(Integer maxRawResultSetSizeForInMemorySort) 806 * @author Andy Hind
781 { 807 */
782 this.maxRawResultSetSizeForInMemorySort = maxRawResultSetSizeForInMemorySort; 808 public static class SortDefinition
783 } 809 {
784 810
785 /** 811 /**
786 * @return true if bulk fetch is enabled 812 * What is used for the sort
787 */ 813 *
788 public boolean isBulkFetchEnabled() 814 * @author andyh
789 { 815 */
790 return isBulkFetchEnabled; 816 public enum SortType
791 } 817 {
792 818 /**
793 /** 819 * A Field
794 * @param isBulkFetchEnabled boolean 820 */
795 */ 821 FIELD,
796 public void setBulkFetchEnabled(boolean isBulkFetchEnabled) 822 /**
797 { 823 * Doc number
798 this.isBulkFetchEnabled = isBulkFetchEnabled; 824 */
799 } 825 DOCUMENT,
800 826 /**
801 827 * Score
802 /** 828 */
803 * A helper class for sort definition. Encapsulated using the lucene sortType, field name and a flag for 829 SCORE
804 * ascending/descending. 830 };
805 * 831
806 * @author Andy Hind 832 SortType sortType;
807 */ 833
808 public static class SortDefinition 834 String field;
809 { 835
810 836 boolean ascending;
811 /** 837
812 * What is used for the sort 838 public SortDefinition(SortType sortType, String field, boolean ascending)
813 * 839 {
814 * @author andyh 840 this.sortType = sortType;
815 */ 841 this.field = field;
816 public enum SortType 842 this.ascending = ascending;
817 { 843 }
818 /** 844
819 * A Field 845 /**
820 */ 846 * Is ascending
821 FIELD, 847 *
822 /** 848 * @return true if ascending
823 * Doc number 849 */
824 */ 850 public boolean isAscending()
825 DOCUMENT, 851 {
826 /** 852 return ascending;
827 * Score 853 }
828 */ 854
829 SCORE 855 /**
830 }; 856 * Field
831 857 *
832 SortType sortType; 858 * @return - the field
833 859 */
834 String field; 860 public String getField()
835 861 {
836 boolean ascending; 862 return field;
837 863 }
838 public SortDefinition(SortType sortType, String field, boolean ascending) 864
839 { 865 /**
840 this.sortType = sortType; 866 * What is used for the sort
841 this.field = field; 867 *
842 this.ascending = ascending; 868 * @return sort type
843 } 869 */
844 870 public SortType getSortType()
845 /** 871 {
846 * Is ascending 872 return sortType;
847 * 873 }
848 * @return true if ascending 874
849 */ 875 }
850 public boolean isAscending() 876
851 { 877 /**
852 return ascending; 878 * @return the default field name
853 } 879 */
854 880 public String getDefaultFieldName()
855 /** 881 {
856 * Field 882 return defaultFieldName;
857 * 883 }
858 * @return - the field 884
859 */ 885 /**
860 public String getField() 886 * @param defaultFieldName - the default field name to use
861 { 887 */
862 return field; 888 public void setDefaultFieldName(String defaultFieldName)
863 } 889 {
864 890 this.defaultFieldName = defaultFieldName;
865 /** 891 }
866 * What is used for the sort 892
867 * 893 public List<FieldFacet> getFieldFacets()
868 * @return sort type 894 {
869 */ 895 return fieldFacets;
870 public SortType getSortType() 896 }
871 { 897
872 return sortType; 898 public void addFieldFacet(FieldFacet fieldFacet)
873 } 899 {
874 900 fieldFacets.add(fieldFacet);
875 } 901 }
876 902
877 /** 903 public List<String> getFacetQueries()
878 * @return the default field name 904 {
879 */ 905 return facetQueries;
880 public String getDefaultFieldName() 906 }
881 { 907
882 return defaultFieldName; 908 public void addFacetQuery(String facetQuery)
883 } 909 {
884 910 facetQueries.add(facetQuery);
885 /** 911 }
886 * @param defaultFieldName - the default field name to use 912
887 */ 913 public List<String> getFilterQueries()
888 public void setDefaultFieldName(String defaultFieldName) 914 {
889 { 915 return filterQueries;
890 this.defaultFieldName = defaultFieldName; 916 }
891 } 917
892 918 public void addFilterQuery(String filterQuery)
893 public List<FieldFacet> getFieldFacets() 919 {
894 { 920 filterQueries.add(filterQuery);
895 return fieldFacets; 921 }
896 } 922
897 923 public Locale getSortLocale()
898 public void addFieldFacet(FieldFacet fieldFacet) 924 {
899 { 925 List<Locale> locales = getLocales();
900 fieldFacets.add(fieldFacet); 926 if (((locales == null) || (locales.size() == 0)))
901 } 927 {
902 928 locales = Collections.singletonList(I18NUtil.getLocale());
903 public List<String> getFacetQueries() 929 }
904 { 930
905 return facetQueries; 931 if (locales.size() > 1)
906 } 932 {
907 933 throw new AlfrescoRuntimeException("Order on text/mltext properties with more than one locale is not curently supported");
908 public void addFacetQuery(String facetQuery) 934 }
909 { 935
910 facetQueries.add(facetQuery); 936 Locale sortLocale = locales.get(0);
911 } 937 return sortLocale;
912 938 }
913 public List<String> getFilterQueries() 939
914 { 940 public void setExcludeTenantFilter(boolean excludeTenantFilter)
915 return filterQueries; 941 {
916 } 942 this.excludeTenantFilter = excludeTenantFilter;
917 943 }
918 public void addFilterQuery(String filterQuery) 944
919 { 945 /**
920 filterQueries.add(filterQuery); 946 *
921 } 947 */
922 948 public boolean getExcludeTenantFilter()
923 public Locale getSortLocale() 949 {
924 { 950 return excludeTenantFilter;
925 List<Locale> locales = getLocales(); 951 }
926 if (((locales == null) || (locales.size() == 0))) 952
927 { 953 public void setQueryConsistency(QueryConsistency queryConsistency)
928 locales = Collections.singletonList(I18NUtil.getLocale()); 954 {
929 } 955 this.queryConsistency = queryConsistency;
930 956 }
931 if (locales.size() > 1) 957
932 { 958 /**
933 throw new AlfrescoRuntimeException("Order on text/mltext properties with more than one locale is not curently supported"); 959 * @return the queryConsistency
934 } 960 */
935 961 public QueryConsistency getQueryConsistency()
936 Locale sortLocale = locales.get(0); 962 {
937 return sortLocale; 963 return queryConsistency;
938 } 964 }
939 965
940 public void setExcludeTenantFilter(boolean excludeTenantFilter) 966
941 { 967 /**
942 this.excludeTenantFilter = excludeTenantFilter; 968 * If not null, then the search should only include results from transactions after {@code sinceTxId}.
943 } 969 * @return sinceTxId
944 970 */
945 /** 971 public Long getSinceTxId()
946 * 972 {
947 */ 973 return this.sinceTxId;
948 public boolean getExcludeTenantFilter() 974 }
949 { 975
950 return excludeTenantFilter; 976 /**
951 } 977 * If not null, then the search should only include results from transactions after {@code sinceTxId}.
952 978 * @param sinceTxId Long
953 public void setQueryConsistency(QueryConsistency queryConsistency) 979 */
954 { 980 public void setSinceTxId(Long sinceTxId)
955 this.queryConsistency = queryConsistency; 981 {
956 } 982 this.sinceTxId = sinceTxId;
957 983 }
958 /** 984
959 * @return the queryConsistency 985 /**
960 */ 986 * @return the searchTerm
961 public QueryConsistency getQueryConsistency() 987 */
962 { 988 public String getSearchTerm()
963 return queryConsistency; 989 {
964 } 990 if((searchTerm == null) || (searchTerm.length() == 0))
965 991 {
966 992 return getQuery();
967 /** 993 }
968 * If not null, then the search should only include results from transactions after {@code sinceTxId}. 994 else
969 * @return sinceTxId 995 {
970 */ 996 return this.searchTerm;
971 public Long getSinceTxId() 997 }
972 { 998 }
973 return this.sinceTxId; 999
974 } 1000 /**
975 1001 * @param searchTerm the searchTerm to set
976 /** 1002 */
977 * If not null, then the search should only include results from transactions after {@code sinceTxId}. 1003 public void setSearchTerm(String searchTerm)
978 * @param sinceTxId Long 1004 {
979 */ 1005 this.searchTerm = searchTerm;
980 public void setSinceTxId(Long sinceTxId) 1006 }
981 { 1007
982 this.sinceTxId = sinceTxId; 1008 /**
983 } 1009 * @return the spellCheck
984 1010 */
985 /** 1011 public boolean isSpellCheck()
986 * @return the searchTerm 1012 {
987 */ 1013 return this.spellCheck;
988 public String getSearchTerm() 1014 }
989 { 1015
990 if((searchTerm == null) || (searchTerm.length() == 0)) 1016 /**
991 { 1017 * @param spellCheck the spellCheck to set
992 return getQuery(); 1018 */
993 } 1019 public void setSpellCheck(boolean spellCheck)
994 else 1020 {
995 { 1021 this.spellCheck = spellCheck;
996 return this.searchTerm; 1022 }
997 } 1023
998 } 1024 /* (non-Javadoc)
999 1025 * @see java.lang.Object#hashCode()
1000 /** 1026 */
1001 * @param searchTerm the searchTerm to set 1027 @Override
1002 */ 1028 public int hashCode()
1003 public void setSearchTerm(String searchTerm) 1029 {
1004 { 1030 final int prime = 31;
1005 this.searchTerm = searchTerm; 1031 int result = 1;
1006 } 1032 result = prime * result + ((allAttributes == null) ? 0 : allAttributes.hashCode());
1007 1033 result = prime * result + ((defaultFTSFieldOperator == null) ? 0 : defaultFTSFieldOperator.hashCode());
1008 /** 1034 result = prime * result + ((defaultFTSOperator == null) ? 0 : defaultFTSOperator.hashCode());
1009 * @return the spellCheck 1035 result = prime * result + ((defaultFieldName == null) ? 0 : defaultFieldName.hashCode());
1010 */ 1036 result = prime * result + (excludeDataInTheCurrentTransaction ? 1231 : 1237);
1011 public boolean isSpellCheck() 1037 result = prime * result + (excludeTenantFilter ? 1231 : 1237);
1012 { 1038 result = prime * result + ((fieldFacets == null) ? 0 : fieldFacets.hashCode());
1013 return this.spellCheck; 1039 result = prime * result + ((language == null) ? 0 : language.hashCode());
1014 } 1040 result = prime * result + limit;
1015 1041 result = prime * result + ((limitBy == null) ? 0 : limitBy.hashCode());
1016 /** 1042 result = prime * result + ((locales == null) ? 0 : locales.hashCode());
1017 * @param spellCheck the spellCheck to set 1043 result = prime * result + maxItems;
1018 */ 1044 result = prime * result + (int) (maxPermissionCheckTimeMillis ^ (maxPermissionCheckTimeMillis >>> 32));
1019 public void setSpellCheck(boolean spellCheck) 1045 result = prime * result + maxPermissionChecks;
1020 { 1046 result = prime * result + ((maxRawResultSetSizeForInMemorySort == null) ? 0 : maxRawResultSetSizeForInMemorySort.hashCode());
1021 this.spellCheck = spellCheck; 1047 result = prime * result + ((mlAnalaysisMode == null) ? 0 : mlAnalaysisMode.hashCode());
1022 } 1048 result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
1023 1049 result = prime * result + ((permissionEvaluation == null) ? 0 : permissionEvaluation.hashCode());
1024 /* (non-Javadoc) 1050 result = prime * result + ((query == null) ? 0 : query.hashCode());
1025 * @see java.lang.Object#hashCode() 1051 result = prime * result + ((queryConsistency == null) ? 0 : queryConsistency.hashCode());
1026 */ 1052 result = prime * result + ((queryParameterDefinitions == null) ? 0 : queryParameterDefinitions.hashCode());
1027 @Override 1053 result = prime * result + ((queryTemplates == null) ? 0 : queryTemplates.hashCode());
1028 public int hashCode() 1054 result = prime * result + skipCount;
1029 { 1055 result = prime * result + ((sortDefinitions == null) ? 0 : sortDefinitions.hashCode());
1030 final int prime = 31; 1056 result = prime * result + ((stores == null) ? 0 : stores.hashCode());
1031 int result = 1; 1057 result = prime * result + ((textAttributes == null) ? 0 : textAttributes.hashCode());
1032 result = prime * result + ((allAttributes == null) ? 0 : allAttributes.hashCode()); 1058 result = prime * result + ((useInMemorySort == null) ? 0 : useInMemorySort.hashCode());
1033 result = prime * result + ((defaultFTSFieldOperator == null) ? 0 : defaultFTSFieldOperator.hashCode()); 1059 result = prime * result + ((sinceTxId == null) ? 0 : sinceTxId.hashCode());
1034 result = prime * result + ((defaultFTSOperator == null) ? 0 : defaultFTSOperator.hashCode()); 1060 result = prime * result + ((facetQueries.isEmpty()) ? 0 : facetQueries.hashCode());
1035 result = prime * result + ((defaultFieldName == null) ? 0 : defaultFieldName.hashCode()); 1061 result = prime * result + ((filterQueries.isEmpty()) ? 0 : filterQueries.hashCode());
1036 result = prime * result + (excludeDataInTheCurrentTransaction ? 1231 : 1237); 1062 result = prime * result + ((searchTerm == null) ? 0 : searchTerm.hashCode());
1037 result = prime * result + (excludeTenantFilter ? 1231 : 1237); 1063 result = prime * result + (spellCheck ? 1231 : 1237);
1038 result = prime * result + ((fieldFacets == null) ? 0 : fieldFacets.hashCode()); 1064 return result;
1039 result = prime * result + ((language == null) ? 0 : language.hashCode()); 1065 }
1040 result = prime * result + limit; 1066
1041 result = prime * result + ((limitBy == null) ? 0 : limitBy.hashCode()); 1067 /* (non-Javadoc)
1042 result = prime * result + ((locales == null) ? 0 : locales.hashCode()); 1068 * @see java.lang.Object#equals(java.lang.Object)
1043 result = prime * result + maxItems; 1069 */
1044 result = prime * result + (int) (maxPermissionCheckTimeMillis ^ (maxPermissionCheckTimeMillis >>> 32)); 1070 @Override
1045 result = prime * result + maxPermissionChecks; 1071 public boolean equals(Object obj)
1046 result = prime * result + ((maxRawResultSetSizeForInMemorySort == null) ? 0 : maxRawResultSetSizeForInMemorySort.hashCode()); 1072 {
1047 result = prime * result + ((mlAnalaysisMode == null) ? 0 : mlAnalaysisMode.hashCode()); 1073 if (this == obj)
1048 result = prime * result + ((namespace == null) ? 0 : namespace.hashCode()); 1074 return true;
1049 result = prime * result + ((permissionEvaluation == null) ? 0 : permissionEvaluation.hashCode()); 1075 if (obj == null)
1050 result = prime * result + ((query == null) ? 0 : query.hashCode()); 1076 return false;
1051 result = prime * result + ((queryConsistency == null) ? 0 : queryConsistency.hashCode()); 1077 if (getClass() != obj.getClass())
1052 result = prime * result + ((queryParameterDefinitions == null) ? 0 : queryParameterDefinitions.hashCode()); 1078 return false;
1053 result = prime * result + ((queryTemplates == null) ? 0 : queryTemplates.hashCode()); 1079 SearchParameters other = (SearchParameters) obj;
1054 result = prime * result + skipCount; 1080 if (allAttributes == null)
1055 result = prime * result + ((sortDefinitions == null) ? 0 : sortDefinitions.hashCode()); 1081 {
1056 result = prime * result + ((stores == null) ? 0 : stores.hashCode()); 1082 if (other.allAttributes != null)
1057 result = prime * result + ((textAttributes == null) ? 0 : textAttributes.hashCode()); 1083 return false;
1058 result = prime * result + ((useInMemorySort == null) ? 0 : useInMemorySort.hashCode()); 1084 }
1059 result = prime * result + ((sinceTxId == null) ? 0 : sinceTxId.hashCode()); 1085 else if (!allAttributes.equals(other.allAttributes))
1060 result = prime * result + ((facetQueries.isEmpty()) ? 0 : facetQueries.hashCode()); 1086 return false;
1061 result = prime * result + ((filterQueries.isEmpty()) ? 0 : filterQueries.hashCode()); 1087 if (defaultFTSFieldOperator != other.defaultFTSFieldOperator)
1062 result = prime * result + ((searchTerm == null) ? 0 : searchTerm.hashCode()); 1088 return false;
1063 result = prime * result + (spellCheck ? 1231 : 1237); 1089 if (defaultFTSOperator != other.defaultFTSOperator)
1064 return result; 1090 return false;
1065 } 1091 if (defaultFieldName == null)
1066 1092 {
1067 /* (non-Javadoc) 1093 if (other.defaultFieldName != null)
1068 * @see java.lang.Object#equals(java.lang.Object) 1094 return false;
1069 */ 1095 }
1070 @Override 1096 else if (!defaultFieldName.equals(other.defaultFieldName))
1071 public boolean equals(Object obj) 1097 return false;
1072 { 1098 if (excludeDataInTheCurrentTransaction != other.excludeDataInTheCurrentTransaction)
1073 if (this == obj) 1099 return false;
1074 return true; 1100 if (excludeTenantFilter != other.excludeTenantFilter)
1075 if (obj == null) 1101 return false;
1076 return false; 1102 if (fieldFacets == null)
1077 if (getClass() != obj.getClass()) 1103 {
1078 return false; 1104 if (other.fieldFacets != null)
1079 SearchParameters other = (SearchParameters) obj; 1105 return false;
1080 if (allAttributes == null) 1106 }
1081 { 1107 else if (!fieldFacets.equals(other.fieldFacets))
1082 if (other.allAttributes != null) 1108 return false;
1083 return false; 1109 if (language == null)
1084 } 1110 {
1085 else if (!allAttributes.equals(other.allAttributes)) 1111 if (other.language != null)
1086 return false; 1112 return false;
1087 if (defaultFTSFieldOperator != other.defaultFTSFieldOperator) 1113 }
1088 return false; 1114 else if (!language.equals(other.language))
1089 if (defaultFTSOperator != other.defaultFTSOperator) 1115 return false;
1090 return false; 1116 if (limit != other.limit)
1091 if (defaultFieldName == null) 1117 return false;
1092 { 1118 if (limitBy != other.limitBy)
1093 if (other.defaultFieldName != null) 1119 return false;
1094 return false; 1120 if (locales == null)
1095 } 1121 {
1096 else if (!defaultFieldName.equals(other.defaultFieldName)) 1122 if (other.locales != null)
1097 return false; 1123 return false;
1098 if (excludeDataInTheCurrentTransaction != other.excludeDataInTheCurrentTransaction) 1124 }
1099 return false; 1125 else if (!locales.equals(other.locales))
1100 if (excludeTenantFilter != other.excludeTenantFilter) 1126 return false;
1101 return false; 1127 if (maxItems != other.maxItems)
1102 if (fieldFacets == null) 1128 return false;
1103 { 1129 if (maxPermissionCheckTimeMillis != other.maxPermissionCheckTimeMillis)
1104 if (other.fieldFacets != null) 1130 return false;
1105 return false; 1131 if (maxPermissionChecks != other.maxPermissionChecks)
1106 } 1132 return false;
1107 else if (!fieldFacets.equals(other.fieldFacets)) 1133 if (maxRawResultSetSizeForInMemorySort == null)
1108 return false; 1134 {
1109 if (language == null) 1135 if (other.maxRawResultSetSizeForInMemorySort != null)
1110 { 1136 return false;
1111 if (other.language != null) 1137 }
1112 return false; 1138 else if (!maxRawResultSetSizeForInMemorySort.equals(other.maxRawResultSetSizeForInMemorySort))
1113 } 1139 return false;
1114 else if (!language.equals(other.language)) 1140 if (mlAnalaysisMode != other.mlAnalaysisMode)
1115 return false; 1141 return false;
1116 if (limit != other.limit) 1142 if (namespace == null)
1117 return false; 1143 {
1118 if (limitBy != other.limitBy) 1144 if (other.namespace != null)
1119 return false; 1145 return false;
1120 if (locales == null) 1146 }
1121 { 1147 else if (!namespace.equals(other.namespace))
1122 if (other.locales != null) 1148 return false;
1123 return false; 1149 if (permissionEvaluation != other.permissionEvaluation)
1124 } 1150 return false;
1125 else if (!locales.equals(other.locales)) 1151 if (query == null)
1126 return false; 1152 {
1127 if (maxItems != other.maxItems) 1153 if (other.query != null)
1128 return false; 1154 return false;
1129 if (maxPermissionCheckTimeMillis != other.maxPermissionCheckTimeMillis) 1155 }
1130 return false; 1156 else if (!query.equals(other.query))
1131 if (maxPermissionChecks != other.maxPermissionChecks) 1157 return false;
1132 return false; 1158 if (queryConsistency != other.queryConsistency)
1133 if (maxRawResultSetSizeForInMemorySort == null) 1159 return false;
1134 { 1160 if (queryParameterDefinitions == null)
1135 if (other.maxRawResultSetSizeForInMemorySort != null) 1161 {
1136 return false; 1162 if (other.queryParameterDefinitions != null)
1137 } 1163 return false;
1138 else if (!maxRawResultSetSizeForInMemorySort.equals(other.maxRawResultSetSizeForInMemorySort)) 1164 }
1139 return false; 1165 else if (!queryParameterDefinitions.equals(other.queryParameterDefinitions))
1140 if (mlAnalaysisMode != other.mlAnalaysisMode) 1166 return false;
1141 return false; 1167 if (queryTemplates == null)
1142 if (namespace == null) 1168 {
1143 { 1169 if (other.queryTemplates != null)
1144 if (other.namespace != null) 1170 return false;
1145 return false; 1171 }
1146 } 1172 else if (!queryTemplates.equals(other.queryTemplates))
1147 else if (!namespace.equals(other.namespace)) 1173 return false;
1148 return false; 1174 if (skipCount != other.skipCount)
1149 if (permissionEvaluation != other.permissionEvaluation) 1175 return false;
1150 return false; 1176 if (sortDefinitions == null)
1151 if (query == null) 1177 {
1152 { 1178 if (other.sortDefinitions != null)
1153 if (other.query != null) 1179 return false;
1154 return false; 1180 }
1155 } 1181 else if (!sortDefinitions.equals(other.sortDefinitions))
1156 else if (!query.equals(other.query)) 1182 return false;
1157 return false; 1183 if (stores == null)
1158 if (queryConsistency != other.queryConsistency) 1184 {
1159 return false; 1185 if (other.stores != null)
1160 if (queryParameterDefinitions == null) 1186 return false;
1161 { 1187 }
1162 if (other.queryParameterDefinitions != null) 1188 else if (!stores.equals(other.stores))
1163 return false; 1189 return false;
1164 } 1190 if (textAttributes == null)
1165 else if (!queryParameterDefinitions.equals(other.queryParameterDefinitions)) 1191 {
1166 return false; 1192 if (other.textAttributes != null)
1167 if (queryTemplates == null) 1193 return false;
1168 { 1194 }
1169 if (other.queryTemplates != null) 1195 else if (!textAttributes.equals(other.textAttributes))
1170 return false; 1196 return false;
1171 } 1197 if (useInMemorySort == null)
1172 else if (!queryTemplates.equals(other.queryTemplates)) 1198 {
1173 return false; 1199 if (other.useInMemorySort != null)
1174 if (skipCount != other.skipCount) 1200 return false;
1175 return false; 1201 }
1176 if (sortDefinitions == null) 1202 else if (!useInMemorySort.equals(other.useInMemorySort))
1177 { 1203 return false;
1178 if (other.sortDefinitions != null) 1204 if (sinceTxId == null)
1179 return false; 1205 {
1180 } 1206 if (other.sinceTxId != null)
1181 else if (!sortDefinitions.equals(other.sortDefinitions)) 1207 return false;
1182 return false; 1208 }
1183 if (stores == null) 1209 else if (!sinceTxId.equals(other.sinceTxId))
1184 { 1210 return false;
1185 if (other.stores != null) 1211 if (!facetQueries.equals(other.facetQueries))
1186 return false; 1212 return false;
1187 } 1213 if (!filterQueries.equals(other.filterQueries))
1188 else if (!stores.equals(other.stores)) 1214 return false;
1189 return false; 1215 if (searchTerm == null)
1190 if (textAttributes == null) 1216 {
1191 { 1217 if (other.searchTerm != null)
1192 if (other.textAttributes != null) 1218 return false;
1193 return false; 1219 }
1194 } 1220 else if (!searchTerm.equals(other.searchTerm))
1195 else if (!textAttributes.equals(other.textAttributes)) 1221 return false;
1196 return false; 1222 if (spellCheck != other.spellCheck)
1197 if (useInMemorySort == null) 1223 return false;
1198 { 1224 return true;
1199 if (other.useInMemorySort != null) 1225 }
1200 return false; 1226
1201 } 1227
1202 else if (!useInMemorySort.equals(other.useInMemorySort)) 1228
1203 return false; 1229 /* (non-Javadoc)
1204 if (sinceTxId == null) 1230 * @see java.lang.Object#toString()
1205 { 1231 */
1206 if (other.sinceTxId != null) 1232 @Override
1207 return false; 1233 public String toString()
1208 } 1234 {
1209 else if (!sinceTxId.equals(other.sinceTxId)) 1235 StringBuilder builder = new StringBuilder(1000);
1210 return false; 1236 builder.append("SearchParameters [language=").append(this.language).append(", query=").append(this.query)
1211 if (!facetQueries.equals(other.facetQueries)) 1237 .append(", stores=").append(this.stores).append(", queryParameterDefinitions=")
1212 return false; 1238 .append(this.queryParameterDefinitions).append(", excludeDataInTheCurrentTransaction=")
1213 if (!filterQueries.equals(other.filterQueries)) 1239 .append(this.excludeDataInTheCurrentTransaction).append(", sortDefinitions=")
1214 return false; 1240 .append(this.sortDefinitions).append(", locales=").append(this.locales)
1215 if (searchTerm == null) 1241 .append(", mlAnalaysisMode=").append(this.mlAnalaysisMode).append(", limitBy=")
1216 { 1242 .append(this.limitBy).append(", permissionEvaluation=").append(this.permissionEvaluation)
1217 if (other.searchTerm != null) 1243 .append(", limit=").append(this.limit).append(", allAttributes=").append(this.allAttributes)
1218 return false; 1244 .append(", textAttributes=").append(this.textAttributes).append(", maxItems=")
1219 } 1245 .append(this.maxItems).append(", skipCount=").append(this.skipCount)
1220 else if (!searchTerm.equals(other.searchTerm)) 1246 .append(", defaultFTSOperator=").append(this.defaultFTSOperator)
1221 return false; 1247 .append(", defaultFTSFieldOperator=").append(this.defaultFTSFieldOperator)
1222 if (spellCheck != other.spellCheck) 1248 .append(", queryTemplates=").append(this.queryTemplates).append(", namespace=")
1223 return false; 1249 .append(this.namespace).append(", maxPermissionChecks=").append(this.maxPermissionChecks)
1224 return true; 1250 .append(", maxPermissionCheckTimeMillis=").append(this.maxPermissionCheckTimeMillis)
1225 } 1251 .append(", defaultFieldName=").append(this.defaultFieldName).append(", fieldFacets=")
1226 1252 .append(this.fieldFacets).append(", facetQueries=").append(this.facetQueries)
1227 1253 .append(this.filterQueries).append(", filterQueries=").append(this.filterQueries)
1228 1254 .append(", useInMemorySort=").append(this.useInMemorySort)
1229 /* (non-Javadoc) 1255 .append(", maxRawResultSetSizeForInMemorySort=").append(this.maxRawResultSetSizeForInMemorySort)
1230 * @see java.lang.Object#toString() 1256 .append(", extraParameters=").append(this.extraParameters).append(", excludeTenantFilter=")
1231 */ 1257 .append(this.excludeTenantFilter).append(", isBulkFetchEnabled=").append(this.isBulkFetchEnabled)
1232 @Override 1258 .append(", queryConsistency=").append(this.queryConsistency).append(", sinceTxId=")
1233 public String toString() 1259 .append(this.sinceTxId).append(", searchTerm=").append(this.searchTerm)
1260 .append(", highlight=").append(this.hightlight)
1234 { 1261 .append(", spellCheck=").append(this.spellCheck).append("]");
1235 StringBuilder builder = new StringBuilder(1000); 1262 return builder.toString();
1236 builder.append("SearchParameters [language=").append(this.language).append(", query=").append(this.query) 1263 }
1237 .append(", stores=").append(this.stores).append(", queryParameterDefinitions=") 1264
1238 .append(this.queryParameterDefinitions).append(", excludeDataInTheCurrentTransaction=") 1265
1239 .append(this.excludeDataInTheCurrentTransaction).append(", sortDefinitions=") 1266 public enum FieldFacetSort
1240 .append(this.sortDefinitions).append(", locales=").append(this.locales) 1267 {
1241 .append(", mlAnalaysisMode=").append(this.mlAnalaysisMode).append(", limitBy=") 1268 COUNT, INDEX;
1242 .append(this.limitBy).append(", permissionEvaluation=").append(this.permissionEvaluation) 1269 }
1243 .append(", limit=").append(this.limit).append(", allAttributes=").append(this.allAttributes) 1270
1244 .append(", textAttributes=").append(this.textAttributes).append(", maxItems=") 1271 public enum FieldFacetMethod
1245 .append(this.maxItems).append(", skipCount=").append(this.skipCount) 1272 {
1246 .append(", defaultFTSOperator=").append(this.defaultFTSOperator) 1273 ENUM, FC;
1247 .append(", defaultFTSFieldOperator=").append(this.defaultFTSFieldOperator) 1274 }
1248 .append(", queryTemplates=").append(this.queryTemplates).append(", namespace=") 1275
1249 .append(this.namespace).append(", maxPermissionChecks=").append(this.maxPermissionChecks) 1276 public static class FieldFacet
1250 .append(", maxPermissionCheckTimeMillis=").append(this.maxPermissionCheckTimeMillis) 1277 {
1251 .append(", defaultFieldName=").append(this.defaultFieldName).append(", fieldFacets=") 1278 String field;
1252 .append(this.fieldFacets).append(", facetQueries=").append(this.facetQueries) 1279 String prefix = null;
1253 .append(this.filterQueries).append(", filterQueries=").append(this.filterQueries) 1280 FieldFacetSort sort = null;
1254 .append(", useInMemorySort=").append(this.useInMemorySort) 1281 Integer limitOrNull = null;
1255 .append(", maxRawResultSetSizeForInMemorySort=").append(this.maxRawResultSetSizeForInMemorySort) 1282 int offset = 0;
1256 .append(", extraParameters=").append(this.extraParameters).append(", excludeTenantFilter=") 1283 int minCount = 0;
1257 .append(this.excludeTenantFilter).append(", isBulkFetchEnabled=").append(this.isBulkFetchEnabled) 1284 boolean countDocsMissingFacetField = false;
1258 .append(", queryConsistency=").append(this.queryConsistency).append(", sinceTxId=") 1285 FieldFacetMethod method = null;
1259 .append(this.sinceTxId).append(", searchTerm=").append(this.searchTerm) 1286 int enumMethodCacheMinDF = 0;
1260 .append(", spellCheck=").append(this.spellCheck).append("]"); 1287
1261 return builder.toString(); 1288 public FieldFacet(String field)
1262 } 1289 {
1263 1290 this.field = field;
1264 1291 }
1265 public enum FieldFacetSort 1292
1266 { 1293 public String getField()
1267 COUNT, INDEX; 1294 {
1268 } 1295 return field;
1269 1296 }
1270 public enum FieldFacetMethod 1297
1271 { 1298 public void setField(String field)
1272 ENUM, FC; 1299 {
1273 } 1300 this.field = field;
1274 1301 }
1275 public static class FieldFacet 1302
1276 { 1303 public String getPrefix()
1277 String field; 1304 {
1278 String prefix = null; 1305 return prefix;
1279 FieldFacetSort sort = null; 1306 }
1280 Integer limitOrNull = null; 1307
1281 int offset = 0; 1308 public void setPrefix(String prefix)
1282 int minCount = 0; 1309 {
1283 boolean countDocsMissingFacetField = false; 1310 this.prefix = prefix;
1284 FieldFacetMethod method = null; 1311 }
1285 int enumMethodCacheMinDF = 0; 1312
1286 1313 public FieldFacetSort getSort()
1287 public FieldFacet(String field) 1314 {
1288 { 1315 return sort;
1289 this.field = field; 1316 }
1290 } 1317
1291 1318 public void setSort(FieldFacetSort sort)
1292 public String getField() 1319 {
1293 { 1320 this.sort = sort;
1294 return field; 1321 }
1295 } 1322
1296 1323 @Deprecated
1297 public void setField(String field) 1324 /**
1298 { 1325 * Will return 100 as the old default but this is now defined in configuration and will be wrong if no explicitly set
1299 this.field = field; 1326 *
1300 } 1327 * @return
1301 1328 */
1302 public String getPrefix() 1329 public int getLimit()
1303 { 1330 {
1304 return prefix; 1331 return limitOrNull == null ? 100 : limitOrNull.intValue();
1305 } 1332 }
1306 1333
1307 public void setPrefix(String prefix) 1334 @Deprecated
1308 { 1335 public void setLimit(int limit)
1309 this.prefix = prefix; 1336 {
1310 } 1337 this.limitOrNull = limit;
1311 1338 }
1312 public FieldFacetSort getSort() 1339
1313 { 1340 public void setLimitOrNull(Integer limitOrNull)
1314 return sort; 1341 {
1315 } 1342 this.limitOrNull = limitOrNull;
1316 1343 }
1317 public void setSort(FieldFacetSort sort) 1344
1318 { 1345
1319 this.sort = sort; 1346 public Integer getLimitOrNull()
1320 } 1347 {
1321 1348 return limitOrNull;
1322 @Deprecated 1349 }
1323 /** 1350
1324 * Will return 100 as the old default but this is now defined in configuration and will be wrong if no explicitly set 1351 public int getOffset()
1325 * 1352 {
1326 * @return 1353 return offset;
1327 */ 1354 }
1328 public int getLimit() 1355
1329 { 1356 public void setOffset(int offset)
1330 return limitOrNull == null ? 100 : limitOrNull.intValue(); 1357 {
1331 } 1358 this.offset = offset;
1332 1359 }
1333 @Deprecated 1360
1334 public void setLimit(int limit) 1361 public int getMinCount()
1335 { 1362 {
1336 this.limitOrNull = limit; 1363 return minCount;
1337 } 1364 }
1338 1365
1339 public void setLimitOrNull(Integer limitOrNull) 1366 public void setMinCount(int minCount)
1340 { 1367 {
1341 this.limitOrNull = limitOrNull; 1368 this.minCount = minCount;
1342 } 1369 }
1343 1370
1344 1371 public boolean isCountDocsMissingFacetField()
1345 public Integer getLimitOrNull() 1372 {
1346 { 1373 return countDocsMissingFacetField;
1347 return limitOrNull; 1374 }
1348 } 1375
1349 1376 public void setCountDocsMissingFacetField(boolean countDocsMissingFacetField)
1350 public int getOffset() 1377 {
1351 { 1378 this.countDocsMissingFacetField = countDocsMissingFacetField;
1352 return offset; 1379 }
1353 } 1380
1354 1381 public FieldFacetMethod getMethod()
1355 public void setOffset(int offset) 1382 {
1356 { 1383 return method;
1357 this.offset = offset; 1384 }
1358 } 1385
1359 1386 public void setMethod(FieldFacetMethod method)
1360 public int getMinCount() 1387 {
1361 { 1388 this.method = method;
1362 return minCount; 1389 }
1363 } 1390
1364 1391 public int getEnumMethodCacheMinDF()
1365 public void setMinCount(int minCount) 1392 {
1366 { 1393 return enumMethodCacheMinDF;
1367 this.minCount = minCount; 1394 }
1368 } 1395
1369 1396 public void setEnumMethodCacheMinDF(int enumMethodCacheMinDF)
1370 public boolean isCountDocsMissingFacetField() 1397 {
1371 { 1398 this.enumMethodCacheMinDF = enumMethodCacheMinDF;
1372 return countDocsMissingFacetField; 1399 }
1373 } 1400
1374 1401 @Override
1375 public void setCountDocsMissingFacetField(boolean countDocsMissingFacetField) 1402 public int hashCode()
1376 { 1403 {
1377 this.countDocsMissingFacetField = countDocsMissingFacetField; 1404 final int prime = 31;
1378 } 1405 int result = 1;
1379 1406 result = prime * result + (countDocsMissingFacetField ? 1231 : 1237);
1380 public FieldFacetMethod getMethod() 1407 result = prime * result + enumMethodCacheMinDF;
1381 { 1408 result = prime * result + ((field == null) ? 0 : field.hashCode());
1382 return method; 1409 result = prime * result + ((limitOrNull == null) ? 0 : limitOrNull.hashCode());
1383 } 1410 result = prime * result + ((method == null) ? 0 : method.hashCode());
1384 1411 result = prime * result + minCount;
1385 public void setMethod(FieldFacetMethod method) 1412 result = prime * result + offset;
1386 { 1413 result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
1387 this.method = method; 1414 result = prime * result + ((sort == null) ? 0 : sort.hashCode());
1388 } 1415 return result;
1389 1416 }
1390 public int getEnumMethodCacheMinDF() 1417
1391 { 1418 @Override
1392 return enumMethodCacheMinDF; 1419 public boolean equals(Object obj)
1393 } 1420 {
1394 1421 if (this == obj)
1395 public void setEnumMethodCacheMinDF(int enumMethodCacheMinDF) 1422 return true;
1396 { 1423 if (obj == null)
1397 this.enumMethodCacheMinDF = enumMethodCacheMinDF; 1424 return false;
1398 } 1425 if (getClass() != obj.getClass())
1399 1426 return false;
1400 @Override 1427 FieldFacet other = (FieldFacet) obj;
1401 public int hashCode() 1428 if (countDocsMissingFacetField != other.countDocsMissingFacetField)
1402 { 1429 return false;
1403 final int prime = 31; 1430 if (enumMethodCacheMinDF != other.enumMethodCacheMinDF)
1404 int result = 1; 1431 return false;
1405 result = prime * result + (countDocsMissingFacetField ? 1231 : 1237); 1432 if (field == null)
1406 result = prime * result + enumMethodCacheMinDF; 1433 {
1407 result = prime * result + ((field == null) ? 0 : field.hashCode()); 1434 if (other.field != null)
1408 result = prime * result + ((limitOrNull == null) ? 0 : limitOrNull.hashCode()); 1435 return false;
1409 result = prime * result + ((method == null) ? 0 : method.hashCode()); 1436 }
1410 result = prime * result + minCount; 1437 else if (!field.equals(other.field))
1411 result = prime * result + offset; 1438 return false;
1412 result = prime * result + ((prefix == null) ? 0 : prefix.hashCode()); 1439 if (limitOrNull == null)
1413 result = prime * result + ((sort == null) ? 0 : sort.hashCode()); 1440 {
1414 return result; 1441 if (other.limitOrNull != null)
1415 } 1442 return false;
1416 1443 }
1417 @Override 1444 else if (!limitOrNull.equals(other.limitOrNull))
1418 public boolean equals(Object obj) 1445 return false;
1419 { 1446 if (method != other.method)
1420 if (this == obj) 1447 return false;
1421 return true; 1448 if (minCount != other.minCount)
1422 if (obj == null) 1449 return false;
1423 return false; 1450 if (offset != other.offset)
1424 if (getClass() != obj.getClass()) 1451 return false;
1425 return false; 1452 if (prefix == null)
1426 FieldFacet other = (FieldFacet) obj; 1453 {
1427 if (countDocsMissingFacetField != other.countDocsMissingFacetField) 1454 if (other.prefix != null)
1428 return false; 1455 return false;
1429 if (enumMethodCacheMinDF != other.enumMethodCacheMinDF) 1456 }
1430 return false; 1457 else if (!prefix.equals(other.prefix))
1431 if (field == null) 1458 return false;
1432 { 1459 if (sort != other.sort)
1433 if (other.field != null) 1460 return false;
1434 return false; 1461 return true;
1435 } 1462 }
1436 else if (!field.equals(other.field)) 1463
1437 return false; 1464
1438 if (limitOrNull == null) 1465 }
1439 { 1466
1440 if (other.limitOrNull != null) 1467 /**
1441 return false; 1468 * @param length int
1442 } 1469 * @param useInMemorySortDefault boolean
1443 else if (!limitOrNull.equals(other.limitOrNull)) 1470 * @param maxRawResultSetSizeForInMemorySortDefault int
1444 return false; 1471 * @return boolean
1445 if (method != other.method) 1472 */
1446 return false; 1473 public boolean usePostSort(int length, boolean useInMemorySortDefault, int maxRawResultSetSizeForInMemorySortDefault)
1447 if (minCount != other.minCount) 1474 {
1448 return false; 1475 boolean use = (useInMemorySort == null) ? useInMemorySortDefault : useInMemorySort.booleanValue();
1449 if (offset != other.offset) 1476 int max = (maxRawResultSetSizeForInMemorySort == null) ? maxRawResultSetSizeForInMemorySortDefault : maxRawResultSetSizeForInMemorySort.intValue();
1450 return false; 1477 return use && (length <= max);
1451 if (prefix == null) 1478 }
1452 { 1479
1453 if (other.prefix != null) 1480 }
1454 return false; 1481