Search in sources :

Example 1 with SearchEngine

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=
}
Also used : ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) SearchEngine(lucee.runtime.search.SearchEngine) DummySearchEngine(lucee.runtime.search.DummySearchEngine) Element(org.w3c.dom.Element)

Example 2 with SearchEngine

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;
}
Also used : SearchEngine(lucee.runtime.search.SearchEngine) ApplicationException(lucee.runtime.exp.ApplicationException) PageException(lucee.runtime.exp.PageException) BundleException(org.osgi.framework.BundleException) SecurityException(lucee.runtime.exp.SecurityException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 3 with 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);
    }
}
Also used : SearchEngine(lucee.runtime.search.SearchEngine) SearchException(lucee.runtime.search.SearchException)

Aggregations

SearchEngine (lucee.runtime.search.SearchEngine)3 IOException (java.io.IOException)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 ExpressionException (lucee.runtime.exp.ExpressionException)1 PageException (lucee.runtime.exp.PageException)1 SecurityException (lucee.runtime.exp.SecurityException)1 DummySearchEngine (lucee.runtime.search.DummySearchEngine)1 SearchException (lucee.runtime.search.SearchException)1 ClassDefinitionImpl (lucee.transformer.library.ClassDefinitionImpl)1 BundleException (org.osgi.framework.BundleException)1 Element (org.w3c.dom.Element)1 SAXException (org.xml.sax.SAXException)1