use of lucee.runtime.search.SearchEngine in project Lucee by lucee.
the class XMLConfigWebFactory method loadSearch.
/**
* @param configServer
* @param config
* @param doc
* @throws PageException
*/
private static void loadSearch(ConfigServer configServer, ConfigImpl config, Document doc) {
Element search = getChildByName(doc.getDocumentElement(), "search");
// class
ClassDefinition<SearchEngine> cd = getClassDefinition(search, "engine-", config.getIdentification());
if (!cd.hasClass() || "lucee.runtime.search.lucene.LuceneSearchEngine".equals(cd.getClassName())) {
if (configServer != null)
cd = ((ConfigImpl) configServer).getSearchEngineClassDefinition();
else
cd = new ClassDefinitionImpl(DummySearchEngine.class);
}
// directory
String dir = search.getAttribute("directory");
if (StringUtil.isEmpty(dir)) {
if (configServer != null)
dir = ((ConfigImpl) configServer).getSearchEngineDirectory();
else
dir = "{lucee-web}/search/";
}
config.setSearchEngine(cd, dir);
// directory=
}
use of lucee.runtime.search.SearchEngine in project Lucee by lucee.
the class ConfigWebImpl method getSearchEngine.
@Override
public SearchEngine getSearchEngine(PageContext pc) throws PageException {
if (searchEngine == null) {
try {
Object o = ClassUtil.loadInstance(getSearchEngineClassDefinition().getClazz());
if (o instanceof SearchEngine)
searchEngine = (SearchEngine) o;
else
throw new ApplicationException("class [" + o.getClass().getName() + "] does not implement the interface SearchEngine");
searchEngine.init(this, ConfigWebUtil.getFile(getConfigDir(), ConfigWebUtil.translateOldPath(getSearchEngineDirectory()), "search", getConfigDir(), FileUtil.TYPE_DIR, this));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
return searchEngine;
}
use of lucee.runtime.search.SearchEngine in project Lucee by lucee.
the class Search method setCollection.
/**
* set the value collection
* The logical collection name that is the target of the search operation or an external collection
* with fully qualified path.
* @param collection value to set
* @throws PageException
*/
public void setCollection(String collection) throws PageException {
String[] collNames = ListUtil.toStringArrayTrim(ListUtil.listToArrayRemoveEmpty(collection, ','));
collections = new SearchCollection[collNames.length];
SearchEngine se = pageContext.getConfig().getSearchEngine(pageContext);
try {
for (int i = 0; i < collections.length; i++) {
collections[i] = se.getCollectionByName(collNames[i]);
}
} catch (SearchException e) {
collections = null;
throw Caster.toPageException(e);
}
}
Aggregations