001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.search; 020 021import java.io.Serializable; 022import java.net.MalformedURLException; 023import java.net.URL; 024 025import lucee.commons.io.log.Log; 026import lucee.commons.io.res.Resource; 027import lucee.runtime.PageContext; 028import lucee.runtime.exp.PageException; 029import lucee.runtime.type.Query; 030import lucee.runtime.type.QueryColumn; 031import lucee.runtime.type.dt.DateTime; 032 033/** 034 * a Search Collection 035 */ 036public interface SearchCollection extends Serializable { 037 038 /** 039 * Field <code>SEARCH_TYPE_SIMPLE</code> 040 */ 041 public static final short SEARCH_TYPE_SIMPLE = 0; 042 043 /** 044 * Field <code>SEARCH_TYPE_EXPLICIT</code> 045 */ 046 public static final short SEARCH_TYPE_EXPLICIT = 1; 047 048 /** 049 * create a collection 050 * @throws SearchException 051 */ 052 public abstract void create() throws SearchException; 053 054 /** 055 * optimize a Collection 056 * @throws SearchException 057 */ 058 public abstract void optimize() throws SearchException; 059 060 /** 061 * map a Collection 062 * @param path 063 * @throws SearchException 064 */ 065 public abstract void map(Resource path) throws SearchException; 066 067 /** 068 * repair a Collection 069 * @throws SearchException 070 */ 071 public abstract void repair() throws SearchException; 072 073 /** 074 * updates a index of a collection 075 * @param pc 076 * @param key 077 * @param type 078 * @param urlpath 079 * @param title 080 * @param body 081 * @param language 082 * @param extensions 083 * @param query 084 * @param recurse 085 * @param categoryTree 086 * @param categories 087 * @param custom1 088 * @param custom2 089 * @param custom3 090 * @param custom4 091 * @throws PageException 092 * @throws MalformedURLException 093 * @throws SearchException 094 */ 095 public abstract IndexResult index(PageContext pc, String key, short type, 096 String urlpath, String title, String body, String language, 097 String[] extensions, String query, boolean recurse, 098 String categoryTree, String[] categories, 099 String custom1, String custom2, String custom3, String custom4) 100 throws PageException, MalformedURLException, SearchException; 101 102 /** 103 * updates a collection with a file 104 * @param id 105 * @param title 106 * @param file 107 * @param language 108 * @throws SearchException 109 */ 110 public abstract IndexResult indexFile(String id, String title, Resource file,String language) throws SearchException; 111 112 /** 113 * updates a collection with a path 114 * @param id 115 * @param title 116 * @param dir 117 * @param recurse 118 * @param extensions 119 * @param language 120 * @throws SearchException 121 */ 122 public abstract IndexResult indexPath(String id, String title, Resource dir, 123 String[] extensions, boolean recurse, String language) 124 throws SearchException; 125 126 /** 127 * updates a collection with a url 128 * @param id 129 * @param title 130 * @param recurse 131 * @param extensions 132 * @param url 133 * @param language 134 * @throws SearchException 135 */ 136 public abstract IndexResult indexURL(String id, String title, URL url, 137 String[] extensions, boolean recurse, String language) 138 throws SearchException; 139 140 /** 141 * updates a collection with a custom 142 * @param id 143 * @param title Title for the Index 144 * @param keyColumn Key Column 145 * @param bodyColumns Body Column Array 146 * @param language Language for index 147 * @param custom1 148 * @param custom2 149 * @param custom3 150 * @param custom4 151 * @throws SearchException 152 */ 153 public abstract IndexResult indexCustom(String id, QueryColumn title, 154 QueryColumn keyColumn, QueryColumn[] bodyColumns, String language,// FUTURE,QueryColumn urlpath, 155 QueryColumn custom1, QueryColumn custom2, QueryColumn custom3,QueryColumn custom4) throws SearchException; 156 157 /** 158 * @return Returns the language. 159 */ 160 public abstract String getLanguage(); 161 162 /** 163 * purge a collection 164 * @throws SearchException 165 */ 166 public abstract IndexResult purge() throws SearchException; 167 168 /** 169 * delete the collection 170 * @throws SearchException 171 */ 172 public abstract IndexResult delete() throws SearchException; 173 174 /** 175 * delete a Index from collection 176 * @param pc 177 * @param key 178 * @param type 179 * @param queryName 180 * @throws SearchException 181 */ 182 public abstract IndexResult deleteIndex(PageContext pc, String key, short type, String queryName) throws SearchException; 183 184 /** 185 * @return Returns the path. 186 */ 187 public abstract Resource getPath(); 188 189 /** 190 * @return returns when collection is created 191 */ 192 public abstract DateTime getCreated(); 193 194 /** 195 * @return Returns the lastUpdate. 196 */ 197 public abstract DateTime getLastUpdate(); 198 199 /** 200 * @return Returns the name. 201 */ 202 public abstract String getName(); 203 204 /** 205 * @return Returns the logFile. 206 */ 207 public abstract Log getLogger(); 208 209 /** 210 * @return Returns the searchEngine. 211 */ 212 public abstract SearchEngine getSearchEngine(); 213 214 /** 215 * return time when collection was created 216 * @return create time 217 */ 218 public abstract Object created(); 219 220 /** 221 * search the collection 222 * @param data 223 * @param qry Query to append resuts 224 * @param criteria 225 * @param language 226 * @param type SEARCH_TYPE_EXPLICIT or SEARCH_TYPE_SIMPLE 227 * @param startrow 228 * @param maxrow 229 * @param categoryTree 230 * @param category 231 * @return new startrow 232 * @throws SearchException 233 * @throws PageException 234 */ 235 public abstract int search(SearchData data, Query qry, 236 String criteria, String language, short type, int startrow, 237 int maxrow, String categoryTree, String[] category) throws SearchException, PageException; 238 239 /** 240 * search the collection 241 * @param data 242 * @param criteria 243 * @param language 244 * @param type SEARCH_TYPE_EXPLICIT or SEARCH_TYPE_SIMPLE 245 * @param categoryTree 246 * @param category 247 * @return Result as SearchRecord Array 248 * @throws SearchException 249 */ 250 public abstract SearchResulItem[] _search(SearchData data, 251 String criteria, String language, short type, String categoryTree, String[] category) 252 throws SearchException; 253 254 /** 255 * @return the size of the collection in KB 256 */ 257 public long getSize(); 258 259 /** 260 * @return the counts of the documents in the collection 261 */ 262 public int getDocumentCount(); 263 264 public int getDocumentCount(String id); 265 266 public abstract Object getCategoryInfo(); 267 268}