xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/SuggesterConfig.java (revision 75e99a6911d39f5a39e0c52c3767fa582c4c4ad8)
1a55b429eSAdam Hornáček /*
2a55b429eSAdam Hornáček  * CDDL HEADER START
3a55b429eSAdam Hornáček  *
4a55b429eSAdam Hornáček  * The contents of this file are subject to the terms of the
5a55b429eSAdam Hornáček  * Common Development and Distribution License (the "License").
6a55b429eSAdam Hornáček  * You may not use this file except in compliance with the License.
7a55b429eSAdam Hornáček  *
8a55b429eSAdam Hornáček  * See LICENSE.txt included in this distribution for the specific
9a55b429eSAdam Hornáček  * language governing permissions and limitations under the License.
10a55b429eSAdam Hornáček  *
11a55b429eSAdam Hornáček  * When distributing Covered Code, include this CDDL HEADER in each
12a55b429eSAdam Hornáček  * file and include the License file at LICENSE.txt.
13a55b429eSAdam Hornáček  * If applicable, add the following below this CDDL HEADER, with the
14a55b429eSAdam Hornáček  * fields enclosed by brackets "[]" replaced with your own identifying
15a55b429eSAdam Hornáček  * information: Portions Copyright [yyyy] [name of copyright owner]
16a55b429eSAdam Hornáček  *
17a55b429eSAdam Hornáček  * CDDL HEADER END
18a55b429eSAdam Hornáček  */
19a55b429eSAdam Hornáček 
20a55b429eSAdam Hornáček /*
21c6f0939bSAdam Hornacek  * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
226c593e21SChris Fraire  * Portions Copyright (c) 2019, Chris Fraire <cfraire@me.com>.
23a55b429eSAdam Hornáček  */
24a55b429eSAdam Hornáček package org.opengrok.indexer.configuration;
25a55b429eSAdam Hornáček 
26a55b429eSAdam Hornáček import com.cronutils.model.CronType;
27a55b429eSAdam Hornáček import com.cronutils.model.definition.CronDefinitionBuilder;
28a55b429eSAdam Hornáček import com.cronutils.parser.CronParser;
29a55b429eSAdam Hornáček import org.opengrok.indexer.search.QueryBuilder;
30a55b429eSAdam Hornáček 
31a55b429eSAdam Hornáček import java.util.Arrays;
32a55b429eSAdam Hornáček import java.util.HashSet;
33a55b429eSAdam Hornáček import java.util.Objects;
34a55b429eSAdam Hornáček import java.util.Set;
35a55b429eSAdam Hornáček 
36a55b429eSAdam Hornáček /**
37a55b429eSAdam Hornáček  * The suggester specific configuration.
38a55b429eSAdam Hornáček  */
39a55b429eSAdam Hornáček public class SuggesterConfig {
40a55b429eSAdam Hornáček 
41a55b429eSAdam Hornáček     public static final boolean ENABLED_DEFAULT = true;
42a55b429eSAdam Hornáček     public static final int MAX_RESULTS_DEFAULT = 10;
43a55b429eSAdam Hornáček     public static final int MIN_CHARS_DEFAULT = 0;
446c593e21SChris Fraire     public static final int MAX_PROJECTS_DEFAULT = Short.MAX_VALUE;
45a55b429eSAdam Hornáček     public static final boolean ALLOW_COMPLEX_QUERIES_DEFAULT = true;
46a55b429eSAdam Hornáček     public static final boolean ALLOW_MOST_POPULAR_DEFAULT = true;
47a55b429eSAdam Hornáček     public static final boolean SHOW_SCORES_DEFAULT = false;
48a55b429eSAdam Hornáček     public static final boolean SHOW_PROJECTS_DEFAULT = true;
49a55b429eSAdam Hornáček     public static final boolean SHOW_TIME_DEFAULT = false;
50a55b429eSAdam Hornáček     public static final String REBUILD_CRON_CONFIG_DEFAULT = "0 0 * * *"; // every day at midnight
51a55b429eSAdam Hornáček     public static final int BUILD_TERMINATION_TIME_DEFAULT = 1800; // half an hour should be enough
52a55b429eSAdam Hornáček     public static final int TIME_THRESHOLD_DEFAULT = 2000; // 2 sec
53a72ebc10SVladimir Kotal     public static final int REBUILD_THREAD_POOL_PERCENT_NCPUS_DEFAULT = 80;
54a55b429eSAdam Hornáček 
55*75e99a69SVladimir Kotal     private static final Set<String> allowedProjectsDefault = null;
56*75e99a69SVladimir Kotal     private static final Set<String> allowedFieldsDefault = Set.of(
57a55b429eSAdam Hornáček             QueryBuilder.FULL,
58a55b429eSAdam Hornáček             QueryBuilder.DEFS,
59a55b429eSAdam Hornáček             QueryBuilder.REFS,
60a55b429eSAdam Hornáček             QueryBuilder.PATH,
61a55b429eSAdam Hornáček             QueryBuilder.HIST,
62a55b429eSAdam Hornáček             QueryBuilder.TYPE
63c6f0939bSAdam Hornacek     );
64a55b429eSAdam Hornáček 
65a55b429eSAdam Hornáček     /**
66a55b429eSAdam Hornáček      * Specifies if the suggester is enabled.
67a55b429eSAdam Hornáček      */
68a55b429eSAdam Hornáček     private boolean enabled;
69a55b429eSAdam Hornáček 
70a55b429eSAdam Hornáček     /**
71*75e99a69SVladimir Kotal      * Specifies maximum number of results suggester should return.
72a55b429eSAdam Hornáček      */
73a55b429eSAdam Hornáček     private int maxResults;
74a55b429eSAdam Hornáček 
75a55b429eSAdam Hornáček     /**
76a55b429eSAdam Hornáček      * Specifies minimum number of characters that are needed for suggester to start looking for suggestions.
77a55b429eSAdam Hornáček      */
78a55b429eSAdam Hornáček     private int minChars;
79a55b429eSAdam Hornáček 
80a55b429eSAdam Hornáček     /**
81a55b429eSAdam Hornáček      * Specifies set of projects for which the suggester should be enabled. If {@code null} then all projects are
82a55b429eSAdam Hornáček      * enabled.
83a55b429eSAdam Hornáček      */
84a55b429eSAdam Hornáček     private Set<String> allowedProjects;
85a55b429eSAdam Hornáček 
86a55b429eSAdam Hornáček     /**
87a55b429eSAdam Hornáček      * Specifies how many maximum projects can be selected at the same time and the suggestions will work.
88a55b429eSAdam Hornáček      */
89a55b429eSAdam Hornáček     private int maxProjects;
90a55b429eSAdam Hornáček 
91a55b429eSAdam Hornáček     /**
92a55b429eSAdam Hornáček      * Specifies the fields for which the suggester should be enabled. If {@code null} then all fields are enabled.
93a55b429eSAdam Hornáček      */
94a55b429eSAdam Hornáček     private Set<String> allowedFields;
95a55b429eSAdam Hornáček 
96a55b429eSAdam Hornáček     /**
97a55b429eSAdam Hornáček      * Specifies if the suggester should support complex queries.
98a55b429eSAdam Hornáček      */
99a55b429eSAdam Hornáček     private boolean allowComplexQueries;
100a55b429eSAdam Hornáček 
101a55b429eSAdam Hornáček     /**
102a55b429eSAdam Hornáček      * Specifies if the most popular completion should be enabled.
103a55b429eSAdam Hornáček      */
104a55b429eSAdam Hornáček     private boolean allowMostPopular;
105a55b429eSAdam Hornáček 
106a55b429eSAdam Hornáček     /**
107a55b429eSAdam Hornáček      * Specifies if the scores should be displayed next to the suggestions.
108a55b429eSAdam Hornáček      */
109a55b429eSAdam Hornáček     private boolean showScores;
110a55b429eSAdam Hornáček 
111a55b429eSAdam Hornáček     /**
112a55b429eSAdam Hornáček      * Specifies if the suggestions should show in which project the term was found.
113a55b429eSAdam Hornáček      */
114a55b429eSAdam Hornáček     private boolean showProjects;
115a55b429eSAdam Hornáček 
116a55b429eSAdam Hornáček     /**
117a55b429eSAdam Hornáček      * Specifies if the time it took the suggester to find the suggestions should be displayed.
118a55b429eSAdam Hornáček      */
119a55b429eSAdam Hornáček     private boolean showTime;
120a55b429eSAdam Hornáček 
121a55b429eSAdam Hornáček     /**
122a55b429eSAdam Hornáček      * Specifies how often should the suggester rebuild the WFST data structures. (Data structures for simple prefix
123a55b429eSAdam Hornáček      * queries.)
124a55b429eSAdam Hornáček      */
125a55b429eSAdam Hornáček     private String rebuildCronConfig;
126a55b429eSAdam Hornáček 
127a55b429eSAdam Hornáček     /**
128a55b429eSAdam Hornáček      * Specifies after how much time (in seconds) the suggester should kill the threads that build the suggester data
129a55b429eSAdam Hornáček      * structures.
130a55b429eSAdam Hornáček      */
131a55b429eSAdam Hornáček     private int buildTerminationTime;
132a55b429eSAdam Hornáček 
133a55b429eSAdam Hornáček     /**
134a55b429eSAdam Hornáček      * Time threshold for suggestions in milliseconds. If the computation exceeds this time,
135a55b429eSAdam Hornáček      * it will be stopped and partial results will be returned.
136a55b429eSAdam Hornáček      */
137a55b429eSAdam Hornáček     private int timeThreshold;
138a55b429eSAdam Hornáček 
139a72ebc10SVladimir Kotal     /**
140a72ebc10SVladimir Kotal      * Number of threads used for rebuild pool expressed in percent of available CPUs in the system.
141a72ebc10SVladimir Kotal      */
142a72ebc10SVladimir Kotal     private int rebuildThreadPoolSizeInNcpuPercent;
143a72ebc10SVladimir Kotal 
SuggesterConfig()144a55b429eSAdam Hornáček     public SuggesterConfig() {
145a55b429eSAdam Hornáček         setEnabled(ENABLED_DEFAULT);
146a55b429eSAdam Hornáček         setMaxResults(MAX_RESULTS_DEFAULT);
147a55b429eSAdam Hornáček         setMinChars(MIN_CHARS_DEFAULT);
148a55b429eSAdam Hornáček         setAllowedProjects(allowedProjectsDefault);
149a55b429eSAdam Hornáček         setMaxProjects(MAX_PROJECTS_DEFAULT);
150a55b429eSAdam Hornáček         setAllowedFields(allowedFieldsDefault);
151a55b429eSAdam Hornáček         setAllowComplexQueries(ALLOW_COMPLEX_QUERIES_DEFAULT);
152a55b429eSAdam Hornáček         setAllowMostPopular(ALLOW_MOST_POPULAR_DEFAULT);
153a55b429eSAdam Hornáček         setShowScores(SHOW_SCORES_DEFAULT);
154a55b429eSAdam Hornáček         setShowProjects(SHOW_PROJECTS_DEFAULT);
155a55b429eSAdam Hornáček         setShowTime(SHOW_TIME_DEFAULT);
156a55b429eSAdam Hornáček         setTimeThreshold(TIME_THRESHOLD_DEFAULT);
157dc67b5a3SVladimir Kotal         setRebuildCronConfig(REBUILD_CRON_CONFIG_DEFAULT);
158a55b429eSAdam Hornáček         setBuildTerminationTime(BUILD_TERMINATION_TIME_DEFAULT);
159a72ebc10SVladimir Kotal         setRebuildThreadPoolSizeInNcpuPercent(REBUILD_THREAD_POOL_PERCENT_NCPUS_DEFAULT);
160a55b429eSAdam Hornáček     }
161a55b429eSAdam Hornáček 
isEnabled()162a55b429eSAdam Hornáček     public boolean isEnabled() {
163a55b429eSAdam Hornáček         return enabled;
164a55b429eSAdam Hornáček     }
165a55b429eSAdam Hornáček 
setEnabled(final boolean enabled)166a55b429eSAdam Hornáček     public void setEnabled(final boolean enabled) {
167a55b429eSAdam Hornáček         this.enabled = enabled;
168a55b429eSAdam Hornáček     }
169a55b429eSAdam Hornáček 
getMaxResults()170a55b429eSAdam Hornáček     public int getMaxResults() {
171a55b429eSAdam Hornáček         return maxResults;
172a55b429eSAdam Hornáček     }
173a55b429eSAdam Hornáček 
setMaxResults(final int maxResults)174a55b429eSAdam Hornáček     public void setMaxResults(final int maxResults) {
175a55b429eSAdam Hornáček         if (maxResults <= 0) {
176a55b429eSAdam Hornáček             throw new IllegalArgumentException("Max results cannot be negative or zero");
177a55b429eSAdam Hornáček         }
178a55b429eSAdam Hornáček         this.maxResults = maxResults;
179a55b429eSAdam Hornáček     }
180a55b429eSAdam Hornáček 
getMinChars()181a55b429eSAdam Hornáček     public int getMinChars() {
182a55b429eSAdam Hornáček         return minChars;
183a55b429eSAdam Hornáček     }
184a55b429eSAdam Hornáček 
setMinChars(final int minChars)185a55b429eSAdam Hornáček     public void setMinChars(final int minChars) {
186a55b429eSAdam Hornáček         if (minChars < 0) {
187a55b429eSAdam Hornáček             throw new IllegalArgumentException(
188a55b429eSAdam Hornáček                     "Minimum number of characters needed for suggester to provide suggestions cannot be negative");
189a55b429eSAdam Hornáček         }
190a55b429eSAdam Hornáček         this.minChars = minChars;
191a55b429eSAdam Hornáček     }
192a55b429eSAdam Hornáček 
getAllowedProjects()193a55b429eSAdam Hornáček     public Set<String> getAllowedProjects() {
194a55b429eSAdam Hornáček         return allowedProjects;
195a55b429eSAdam Hornáček     }
196a55b429eSAdam Hornáček 
setAllowedProjects(final Set<String> allowedProjects)197a55b429eSAdam Hornáček     public void setAllowedProjects(final Set<String> allowedProjects) {
198a55b429eSAdam Hornáček         this.allowedProjects = allowedProjects;
199a55b429eSAdam Hornáček     }
200a55b429eSAdam Hornáček 
getMaxProjects()201a55b429eSAdam Hornáček     public int getMaxProjects() {
202a55b429eSAdam Hornáček         return maxProjects;
203a55b429eSAdam Hornáček     }
204a55b429eSAdam Hornáček 
setMaxProjects(final int maxProjects)205a55b429eSAdam Hornáček     public void setMaxProjects(final int maxProjects) {
206a55b429eSAdam Hornáček         if (maxProjects < 1) {
207a55b429eSAdam Hornáček             throw new IllegalArgumentException("Maximum projects for suggestions cannot be less than 1");
208a55b429eSAdam Hornáček         }
209a55b429eSAdam Hornáček         this.maxProjects = maxProjects;
210a55b429eSAdam Hornáček     }
211a55b429eSAdam Hornáček 
getAllowedFields()212a55b429eSAdam Hornáček     public Set<String> getAllowedFields() {
213a55b429eSAdam Hornáček         return allowedFields;
214a55b429eSAdam Hornáček     }
215a55b429eSAdam Hornáček 
setAllowedFields(final Set<String> allowedFields)216a55b429eSAdam Hornáček     public void setAllowedFields(final Set<String> allowedFields) {
217c6f0939bSAdam Hornacek         this.allowedFields = new HashSet<>(allowedFields);
218a55b429eSAdam Hornáček     }
219a55b429eSAdam Hornáček 
isAllowComplexQueries()220a55b429eSAdam Hornáček     public boolean isAllowComplexQueries() {
221a55b429eSAdam Hornáček         return allowComplexQueries;
222a55b429eSAdam Hornáček     }
223a55b429eSAdam Hornáček 
setAllowComplexQueries(final boolean allowComplexQueries)224a55b429eSAdam Hornáček     public void setAllowComplexQueries(final boolean allowComplexQueries) {
225a55b429eSAdam Hornáček         this.allowComplexQueries = allowComplexQueries;
226a55b429eSAdam Hornáček     }
227a55b429eSAdam Hornáček 
isAllowMostPopular()228a55b429eSAdam Hornáček     public boolean isAllowMostPopular() {
229a55b429eSAdam Hornáček         return allowMostPopular;
230a55b429eSAdam Hornáček     }
231a55b429eSAdam Hornáček 
setAllowMostPopular(final boolean allowMostPopular)232a55b429eSAdam Hornáček     public void setAllowMostPopular(final boolean allowMostPopular) {
233a55b429eSAdam Hornáček         this.allowMostPopular = allowMostPopular;
234a55b429eSAdam Hornáček     }
235a55b429eSAdam Hornáček 
isShowScores()236a55b429eSAdam Hornáček     public boolean isShowScores() {
237a55b429eSAdam Hornáček         return showScores;
238a55b429eSAdam Hornáček     }
239a55b429eSAdam Hornáček 
setShowScores(final boolean showScores)240a55b429eSAdam Hornáček     public void setShowScores(final boolean showScores) {
241a55b429eSAdam Hornáček         this.showScores = showScores;
242a55b429eSAdam Hornáček     }
243a55b429eSAdam Hornáček 
isShowProjects()244a55b429eSAdam Hornáček     public boolean isShowProjects() {
245a55b429eSAdam Hornáček         return showProjects;
246a55b429eSAdam Hornáček     }
247a55b429eSAdam Hornáček 
setShowProjects(final boolean showProjects)248a55b429eSAdam Hornáček     public void setShowProjects(final boolean showProjects) {
249a55b429eSAdam Hornáček         this.showProjects = showProjects;
250a55b429eSAdam Hornáček     }
251a55b429eSAdam Hornáček 
isShowTime()252a55b429eSAdam Hornáček     public boolean isShowTime() {
253a55b429eSAdam Hornáček         return showTime;
254a55b429eSAdam Hornáček     }
255a55b429eSAdam Hornáček 
setShowTime(final boolean showTime)256a55b429eSAdam Hornáček     public void setShowTime(final boolean showTime) {
257a55b429eSAdam Hornáček         this.showTime = showTime;
258a55b429eSAdam Hornáček     }
259a55b429eSAdam Hornáček 
getRebuildCronConfig()260a55b429eSAdam Hornáček     public String getRebuildCronConfig() {
261a55b429eSAdam Hornáček         return rebuildCronConfig;
262a55b429eSAdam Hornáček     }
263a55b429eSAdam Hornáček 
setRebuildCronConfig(final String rebuildCronConfig)264a55b429eSAdam Hornáček     public void setRebuildCronConfig(final String rebuildCronConfig) {
265a55b429eSAdam Hornáček         if (rebuildCronConfig != null) { // check cron format
266a55b429eSAdam Hornáček             CronParser parser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX));
267a55b429eSAdam Hornáček             parser.parse(rebuildCronConfig); // throws IllegalArgumentException if invalid
268a55b429eSAdam Hornáček         }
269a55b429eSAdam Hornáček         this.rebuildCronConfig = rebuildCronConfig;
270a55b429eSAdam Hornáček     }
271a55b429eSAdam Hornáček 
getBuildTerminationTime()272a55b429eSAdam Hornáček     public int getBuildTerminationTime() {
273a55b429eSAdam Hornáček         return buildTerminationTime;
274a55b429eSAdam Hornáček     }
275a55b429eSAdam Hornáček 
setBuildTerminationTime(final int buildTerminationTime)276a55b429eSAdam Hornáček     public void setBuildTerminationTime(final int buildTerminationTime) {
277a55b429eSAdam Hornáček         if (buildTerminationTime < 0) {
278a55b429eSAdam Hornáček             throw new IllegalArgumentException("Suggester build termination time cannot be negative");
279a55b429eSAdam Hornáček         }
280a55b429eSAdam Hornáček         this.buildTerminationTime = buildTerminationTime;
281a55b429eSAdam Hornáček     }
282a55b429eSAdam Hornáček 
getTimeThreshold()283a55b429eSAdam Hornáček     public int getTimeThreshold() {
284a55b429eSAdam Hornáček         return timeThreshold;
285a55b429eSAdam Hornáček     }
286a55b429eSAdam Hornáček 
setTimeThreshold(final int timeThreshold)287a55b429eSAdam Hornáček     public void setTimeThreshold(final int timeThreshold) {
288a55b429eSAdam Hornáček         if (timeThreshold < 0) {
289a55b429eSAdam Hornáček             throw new IllegalArgumentException("Time threshold for suggestions cannot be negative");
290a55b429eSAdam Hornáček         }
291a55b429eSAdam Hornáček         this.timeThreshold = timeThreshold;
292a55b429eSAdam Hornáček     }
293a55b429eSAdam Hornáček 
setRebuildThreadPoolSizeInNcpuPercent(final int percent)294a72ebc10SVladimir Kotal     public void setRebuildThreadPoolSizeInNcpuPercent(final int percent) {
295a72ebc10SVladimir Kotal         if (percent < 0 || percent > 100) {
296a72ebc10SVladimir Kotal             throw new IllegalArgumentException("Need percentage value");
297a72ebc10SVladimir Kotal         }
298a72ebc10SVladimir Kotal         this.rebuildThreadPoolSizeInNcpuPercent = percent;
299a72ebc10SVladimir Kotal     }
300a72ebc10SVladimir Kotal 
getRebuildThreadPoolSizeInNcpuPercent()301a72ebc10SVladimir Kotal     public int getRebuildThreadPoolSizeInNcpuPercent() {
302a72ebc10SVladimir Kotal         return rebuildThreadPoolSizeInNcpuPercent;
303a72ebc10SVladimir Kotal     }
304a72ebc10SVladimir Kotal 
305a55b429eSAdam Hornáček     @Override
equals(Object o)306a55b429eSAdam Hornáček     public boolean equals(Object o) {
307a55b429eSAdam Hornáček         if (this == o) {
308a55b429eSAdam Hornáček             return true;
309a55b429eSAdam Hornáček         }
310a55b429eSAdam Hornáček         if (o == null || getClass() != o.getClass()) {
311a55b429eSAdam Hornáček             return false;
312a55b429eSAdam Hornáček         }
313a55b429eSAdam Hornáček         SuggesterConfig that = (SuggesterConfig) o;
314a55b429eSAdam Hornáček         return enabled == that.enabled &&
315a55b429eSAdam Hornáček                 maxResults == that.maxResults &&
316a55b429eSAdam Hornáček                 minChars == that.minChars &&
317a55b429eSAdam Hornáček                 maxProjects == that.maxProjects &&
318a55b429eSAdam Hornáček                 allowComplexQueries == that.allowComplexQueries &&
319a55b429eSAdam Hornáček                 allowMostPopular == that.allowMostPopular &&
320a55b429eSAdam Hornáček                 showScores == that.showScores &&
321a55b429eSAdam Hornáček                 showProjects == that.showProjects &&
322a55b429eSAdam Hornáček                 showTime == that.showTime &&
323a55b429eSAdam Hornáček                 buildTerminationTime == that.buildTerminationTime &&
324a55b429eSAdam Hornáček                 Objects.equals(allowedProjects, that.allowedProjects) &&
325a55b429eSAdam Hornáček                 Objects.equals(allowedFields, that.allowedFields) &&
326a72ebc10SVladimir Kotal                 Objects.equals(rebuildCronConfig, that.rebuildCronConfig) &&
327a72ebc10SVladimir Kotal                 rebuildThreadPoolSizeInNcpuPercent == that.rebuildThreadPoolSizeInNcpuPercent;
328a55b429eSAdam Hornáček     }
329a55b429eSAdam Hornáček 
330a55b429eSAdam Hornáček     @Override
hashCode()331a55b429eSAdam Hornáček     public int hashCode() {
332a55b429eSAdam Hornáček         return Objects.hash(enabled, maxResults, minChars, allowedProjects, maxProjects, allowedFields,
333a55b429eSAdam Hornáček                 allowComplexQueries, allowMostPopular, showScores, showProjects, showTime, rebuildCronConfig,
334a72ebc10SVladimir Kotal                 buildTerminationTime, rebuildThreadPoolSizeInNcpuPercent);
335a55b429eSAdam Hornáček     }
336a55b429eSAdam Hornáček 
3376c593e21SChris Fraire     /**
3386c593e21SChris Fraire      * Gets an instance version suitable for helper documentation by shifting
3396c593e21SChris Fraire      * most default properties slightly.
3406c593e21SChris Fraire      */
getForHelp()3416c593e21SChris Fraire     static SuggesterConfig getForHelp() {
3426c593e21SChris Fraire         SuggesterConfig res = new SuggesterConfig();
3436c593e21SChris Fraire         res.setEnabled(!res.isEnabled());
3446c593e21SChris Fraire         res.setMaxResults(1 + res.getMaxResults());
3456c593e21SChris Fraire         res.setMinChars(1 + res.getMinChars());
3466c593e21SChris Fraire         res.setAllowedProjects(new HashSet<>(Arrays.asList("project-1", "project-2")));
3476c593e21SChris Fraire         res.setMaxProjects(1 + res.getMaxProjects());
3486c593e21SChris Fraire         res.setAllowedFields(getAllowedFieldsForHelp(res.getAllowedFields()));
3496c593e21SChris Fraire         res.setAllowComplexQueries(!res.isAllowComplexQueries());
3506c593e21SChris Fraire         res.setAllowMostPopular(!res.isAllowMostPopular());
3516c593e21SChris Fraire         res.setShowScores(!res.isShowScores());
3526c593e21SChris Fraire         res.setShowProjects(!res.isShowProjects());
3536c593e21SChris Fraire         res.setShowTime(!res.isShowTime());
3546c593e21SChris Fraire         res.setTimeThreshold(1 + res.getTimeThreshold());
3556c593e21SChris Fraire         res.setRebuildCronConfig("1 0 * * *");
3566c593e21SChris Fraire         res.setBuildTerminationTime(1 + res.getBuildTerminationTime());
3576c593e21SChris Fraire         res.setRebuildThreadPoolSizeInNcpuPercent(1 + res.getRebuildThreadPoolSizeInNcpuPercent());
3586c593e21SChris Fraire         return res;
3596c593e21SChris Fraire     }
3606c593e21SChris Fraire 
getAllowedFieldsForHelp(Set<String> allowedFields)3616c593e21SChris Fraire     private static HashSet<String> getAllowedFieldsForHelp(Set<String> allowedFields) {
3626c593e21SChris Fraire         HashSet<String> res = new HashSet<>(allowedFields);
3636c593e21SChris Fraire         res.remove(QueryBuilder.FULL);
3646c593e21SChris Fraire         return res;
3656c593e21SChris Fraire     }
366a55b429eSAdam Hornáček }
367