View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.entity;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import org.codelibs.fess.util.FacetResponse;
22  
23  /**
24   * Data container for search results rendering.
25   *
26   * This class holds all the data needed to render search results in the UI,
27   * including the actual search results, pagination information, facet data,
28   * execution timing, and highlighting parameters.
29   */
30  public class SearchRenderData {
31  
32      /** List of search result documents. */
33      protected List<Map<String, Object>> documentItems;
34  
35      /** Facet response containing aggregated search facets. */
36      protected FacetResponse facetResponse;
37  
38      /** Additional highlight parameters to append to URLs. */
39      protected String appendHighlightParams;
40  
41      /** Formatted execution time for the search request. */
42      protected String execTime;
43  
44      /** Number of results per page. */
45      protected int pageSize;
46  
47      /** Current page number being displayed. */
48      protected int currentPageNumber;
49  
50      /** Total number of records matching the search query. */
51      protected long allRecordCount;
52  
53      /** Relation type for the record count (e.g., "eq", "gte"). */
54      protected String allRecordCountRelation;
55  
56      /** Total number of pages based on record count and page size. */
57      protected int allPageCount;
58  
59      /** Flag indicating whether a next page exists. */
60      protected boolean existNextPage;
61  
62      /** Flag indicating whether a previous page exists. */
63      protected boolean existPrevPage;
64  
65      /** Starting record number for the current page. */
66      protected long currentStartRecordNumber;
67  
68      /** Ending record number for the current page. */
69      protected long currentEndRecordNumber;
70  
71      /** List of page numbers for pagination navigation. */
72      protected List<String> pageNumberList;
73  
74      /** Flag indicating whether the results are partial due to timeout or other issues. */
75      protected boolean partialResults;
76  
77      /** The actual search query executed against the search engine. */
78      protected String searchQuery;
79  
80      /** Time taken to execute the search query in milliseconds. */
81      protected long queryTime;
82  
83      /** Timestamp when the search request was made. */
84      protected long requestedTime;
85  
86      /** Unique identifier for this search query session. */
87      protected String queryId;
88  
89      /**
90       * Default constructor for creating a new SearchRenderData instance.
91       */
92      public SearchRenderData() {
93          // Default constructor
94      }
95  
96      /**
97       * Sets the list of search result documents.
98       *
99       * @param documentItems The list of search result documents
100      */
101     public void setDocumentItems(final List<Map<String, Object>> documentItems) {
102         this.documentItems = documentItems;
103     }
104 
105     /**
106      * Sets the facet response containing aggregated search facets.
107      *
108      * @param facetResponse The facet response
109      */
110     public void setFacetResponse(final FacetResponse facetResponse) {
111         this.facetResponse = facetResponse;
112     }
113 
114     /**
115      * Sets additional highlight parameters to append to URLs.
116      *
117      * @param appendHighlightParams The highlight parameters string
118      */
119     public void setAppendHighlightParams(final String appendHighlightParams) {
120         this.appendHighlightParams = appendHighlightParams;
121     }
122 
123     /**
124      * Sets the formatted execution time for the search request.
125      *
126      * @param execTime The formatted execution time string
127      */
128     public void setExecTime(final String execTime) {
129         this.execTime = execTime;
130     }
131 
132     /**
133      * Sets the number of results per page.
134      *
135      * @param pageSize The page size
136      */
137     public void setPageSize(final int pageSize) {
138         this.pageSize = pageSize;
139     }
140 
141     /**
142      * Sets the current page number being displayed.
143      *
144      * @param currentPageNumber The current page number
145      */
146     public void setCurrentPageNumber(final int currentPageNumber) {
147         this.currentPageNumber = currentPageNumber;
148     }
149 
150     /**
151      * Sets the total number of records matching the search query.
152      *
153      * @param allRecordCount The total record count
154      */
155     public void setAllRecordCount(final long allRecordCount) {
156         this.allRecordCount = allRecordCount;
157     }
158 
159     /**
160      * Sets the relation type for the record count (e.g., "eq", "gte").
161      *
162      * @param allRecordCountRelation The record count relation
163      */
164     public void setAllRecordCountRelation(final String allRecordCountRelation) {
165         this.allRecordCountRelation = allRecordCountRelation;
166     }
167 
168     /**
169      * Sets the total number of pages based on record count and page size.
170      *
171      * @param allPageCount The total page count
172      */
173     public void setAllPageCount(final int allPageCount) {
174         this.allPageCount = allPageCount;
175     }
176 
177     /**
178      * Sets whether a next page exists.
179      *
180      * @param existNextPage true if a next page exists
181      */
182     public void setExistNextPage(final boolean existNextPage) {
183         this.existNextPage = existNextPage;
184     }
185 
186     /**
187      * Sets whether a previous page exists.
188      *
189      * @param existPrevPage true if a previous page exists
190      */
191     public void setExistPrevPage(final boolean existPrevPage) {
192         this.existPrevPage = existPrevPage;
193     }
194 
195     /**
196      * Sets the starting record number for the current page.
197      *
198      * @param currentStartRecordNumber The starting record number
199      */
200     public void setCurrentStartRecordNumber(final long currentStartRecordNumber) {
201         this.currentStartRecordNumber = currentStartRecordNumber;
202     }
203 
204     /**
205      * Sets the ending record number for the current page.
206      *
207      * @param currentEndRecordNumber The ending record number
208      */
209     public void setCurrentEndRecordNumber(final long currentEndRecordNumber) {
210         this.currentEndRecordNumber = currentEndRecordNumber;
211     }
212 
213     /**
214      * Sets the list of page numbers for pagination navigation.
215      *
216      * @param pageNumberList The page number list
217      */
218     public void setPageNumberList(final List<String> pageNumberList) {
219         this.pageNumberList = pageNumberList;
220     }
221 
222     /**
223      * Sets whether the results are partial due to timeout or other issues.
224      *
225      * @param partialResults true if results are partial
226      */
227     public void setPartialResults(final boolean partialResults) {
228         this.partialResults = partialResults;
229     }
230 
231     /**
232      * Sets the time taken to execute the search query in milliseconds.
233      *
234      * @param queryTime The query execution time in milliseconds
235      */
236     public void setQueryTime(final long queryTime) {
237         this.queryTime = queryTime;
238     }
239 
240     /**
241      * Sets the actual search query executed against the search engine.
242      *
243      * @param searchQuery The search query string
244      */
245     public void setSearchQuery(final String searchQuery) {
246         this.searchQuery = searchQuery;
247     }
248 
249     /**
250      * Sets the timestamp when the search request was made.
251      *
252      * @param requestedTime The request timestamp
253      */
254     public void setRequestedTime(final long requestedTime) {
255         this.requestedTime = requestedTime;
256     }
257 
258     /**
259      * Sets the unique identifier for this search query session.
260      *
261      * @param queryId The query identifier
262      */
263     public void setQueryId(final String queryId) {
264         this.queryId = queryId;
265     }
266 
267     /**
268      * Gets the list of search result documents.
269      *
270      * @return The list of search result documents
271      */
272     public List<Map<String, Object>> getDocumentItems() {
273         return documentItems;
274     }
275 
276     /**
277      * Gets the facet response containing aggregated search facets.
278      *
279      * @return The facet response
280      */
281     public FacetResponse getFacetResponse() {
282         return facetResponse;
283     }
284 
285     /**
286      * Gets additional highlight parameters to append to URLs.
287      *
288      * @return The highlight parameters string
289      */
290     public String getAppendHighlightParams() {
291         return appendHighlightParams;
292     }
293 
294     /**
295      * Gets the formatted execution time for the search request.
296      *
297      * @return The formatted execution time string
298      */
299     public String getExecTime() {
300         return execTime;
301     }
302 
303     /**
304      * Gets the number of results per page.
305      *
306      * @return The page size
307      */
308     public int getPageSize() {
309         return pageSize;
310     }
311 
312     /**
313      * Gets the current page number being displayed.
314      *
315      * @return The current page number
316      */
317     public int getCurrentPageNumber() {
318         return currentPageNumber;
319     }
320 
321     /**
322      * Gets the total number of records matching the search query.
323      *
324      * @return The total record count
325      */
326     public long getAllRecordCount() {
327         return allRecordCount;
328     }
329 
330     /**
331      * Gets the relation type for the record count (e.g., "eq", "gte").
332      *
333      * @return The record count relation
334      */
335     public String getAllRecordCountRelation() {
336         return allRecordCountRelation;
337     }
338 
339     /**
340      * Gets the total number of pages based on record count and page size.
341      *
342      * @return The total page count
343      */
344     public int getAllPageCount() {
345         return allPageCount;
346     }
347 
348     /**
349      * Checks whether a next page exists.
350      *
351      * @return true if a next page exists
352      */
353     public boolean isExistNextPage() {
354         return existNextPage;
355     }
356 
357     /**
358      * Checks whether a previous page exists.
359      *
360      * @return true if a previous page exists
361      */
362     public boolean isExistPrevPage() {
363         return existPrevPage;
364     }
365 
366     /**
367      * Gets the starting record number for the current page.
368      *
369      * @return The starting record number
370      */
371     public long getCurrentStartRecordNumber() {
372         return currentStartRecordNumber;
373     }
374 
375     /**
376      * Gets the ending record number for the current page.
377      *
378      * @return The ending record number
379      */
380     public long getCurrentEndRecordNumber() {
381         return currentEndRecordNumber;
382     }
383 
384     /**
385      * Gets the list of page numbers for pagination navigation.
386      *
387      * @return The page number list
388      */
389     public List<String> getPageNumberList() {
390         return pageNumberList;
391     }
392 
393     /**
394      * Checks whether the results are partial due to timeout or other issues.
395      *
396      * @return true if results are partial
397      */
398     public boolean isPartialResults() {
399         return partialResults;
400     }
401 
402     /**
403      * Gets the actual search query executed against the search engine.
404      *
405      * @return The search query string
406      */
407     public String getSearchQuery() {
408         return searchQuery;
409     }
410 
411     /**
412      * Gets the time taken to execute the search query in milliseconds.
413      *
414      * @return The query execution time in milliseconds
415      */
416     public long getQueryTime() {
417         return queryTime;
418     }
419 
420     /**
421      * Gets the timestamp when the search request was made.
422      *
423      * @return The request timestamp
424      */
425     public long getRequestedTime() {
426         return requestedTime;
427     }
428 
429     /**
430      * Gets the unique identifier for this search query session.
431      *
432      * @return The query identifier
433      */
434     public String getQueryId() {
435         return queryId;
436     }
437 
438     @Override
439     public String toString() {
440         return "SearchRenderData [documentItems=" + documentItems + ", facetResponse=" + facetResponse + ", appendHighlightParams="
441                 + appendHighlightParams + ", execTime=" + execTime + ", pageSize=" + pageSize + ", currentPageNumber=" + currentPageNumber
442                 + ", allRecordCount=" + allRecordCount + ", allRecordCountRelation=" + allRecordCountRelation + ", allPageCount="
443                 + allPageCount + ", existNextPage=" + existNextPage + ", existPrevPage=" + existPrevPage + ", currentStartRecordNumber="
444                 + currentStartRecordNumber + ", currentEndRecordNumber=" + currentEndRecordNumber + ", pageNumberList=" + pageNumberList
445                 + ", partialResults=" + partialResults + ", searchQuery=" + searchQuery + ", queryTime=" + queryTime + ", requestedTime="
446                 + requestedTime + ", queryId=" + queryId + "]";
447     }
448 
449 }