use of org.apache.jackrabbit.core.query.lucene.SearchIndex in project jackrabbit-oak by apache.
the class IndexAccessor method getReader.
public static IndexReader getReader(RepositoryContext ctx) throws RepositoryException, IOException {
RepositoryImpl repo = ctx.getRepository();
SearchManager searchMgr = repo.getSearchManager(ctx.getRepositoryConfig().getDefaultWorkspaceName());
if (searchMgr == null) {
return null;
}
QueryHandler handler = searchMgr.getQueryHandler();
SearchIndex index = (SearchIndex) handler;
return index.getIndexReader();
}
use of org.apache.jackrabbit.core.query.lucene.SearchIndex in project jackrabbit by apache.
the class QueryObjectModelImpl method init.
/**
* Initializes a query instance from a query object model.
*
* @param sessionContext component context of the current session
* @param handler the query handler of the search index.
* @param qomTree the query object model tree.
* @param language the original query syntax from where the JQOM was
* created.
* @param node a nt:query node where the query was read from or
* <code>null</code> if it is not a stored query.
* @throws InvalidQueryException if the qom tree cannot be serialized
* according to the given language.
* @throws RepositoryException if another error occurs
*/
public void init(SessionContext sessionContext, QueryHandler handler, QueryObjectModelTree qomTree, String language, Node node) throws InvalidQueryException, RepositoryException {
checkNotInitialized();
this.sessionContext = sessionContext;
this.language = language;
this.handler = handler;
this.qomTree = qomTree;
this.node = node;
this.statement = QueryObjectModelBuilderRegistry.getQueryObjectModelBuilder(language).toString(this);
try {
qomTree.accept(new DefaultTraversingQOMTreeVisitor() {
@Override
public Object visit(BindVariableValueImpl node, Object data) {
variables.put(node.getBindVariableName(), null);
return data;
}
}, null);
} catch (Exception ignore) {
}
this.lqf = new LuceneQueryFactory(sessionContext.getSessionImpl(), (SearchIndex) handler, variables);
setInitialized();
}
use of org.apache.jackrabbit.core.query.lucene.SearchIndex in project jackrabbit by apache.
the class TestHelper method checkIndexConsistency.
public static ConsistencyCheck checkIndexConsistency(Session session) throws RepositoryException, NotExecutableException, IOException {
Repository r = session.getRepository();
if (!(r instanceof RepositoryImpl)) {
throw new NotExecutableException();
}
RepositoryImpl ri = (RepositoryImpl) r;
final String workspaceName = session.getWorkspace().getName();
QueryHandler qh = ri.getSearchManager(workspaceName).getQueryHandler();
if (!(qh instanceof SearchIndex)) {
throw new NotExecutableException("No search index");
}
SearchIndex si = (SearchIndex) qh;
return si.runConsistencyCheck();
}
Aggregations