use of com.orientechnologies.orient.core.sql.parser.ParseException in project orientdb by orientechnologies.
the class OCommandExecutorScript method executeInContext.
public Object executeInContext(final OCommandContext iContext, final Map<Object, Object> iArgs) {
final String language = request.getLanguage();
parserText = request.getText();
parameters = iArgs;
parameters = iArgs;
if (language.equalsIgnoreCase("SQL")) {
// SPECIAL CASE: EXECUTE THE COMMANDS IN SEQUENCE
try {
parserText = preParse(parserText, iArgs);
} catch (ParseException e) {
throw new OCommandExecutionException("Invalid script:" + e.getMessage());
}
return executeSQL();
} else {
return executeJsr223Script(language, iContext, iArgs);
}
}
use of com.orientechnologies.orient.core.sql.parser.ParseException in project orientdb by orientechnologies.
the class OLuceneTextOperator method evaluateRecord.
@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft, Object iRight, OCommandContext iContext) {
OLuceneFullTextIndex index = involvedIndex(iRecord, iCurrentResult, iCondition, iLeft, iRight);
if (index == null) {
throw new OCommandExecutionException("Cannot evaluate lucene condition without index configuration.");
}
MemoryIndex memoryIndex = (MemoryIndex) iContext.getVariable(MEMORY_INDEX);
if (memoryIndex == null) {
memoryIndex = new MemoryIndex();
iContext.setVariable(MEMORY_INDEX, memoryIndex);
}
memoryIndex.reset();
try {
for (IndexableField field : index.buildDocument(iLeft).getFields()) {
memoryIndex.addField(field.name(), field.tokenStream(index.indexAnalyzer(), null));
}
return memoryIndex.search(index.buildQuery(iRight)) > 0.0f;
} catch (ParseException e) {
OLogManager.instance().error(this, "error occurred while building query", e);
} catch (IOException e) {
OLogManager.instance().error(this, "error occurred while building memory index", e);
}
return null;
}
use of com.orientechnologies.orient.core.sql.parser.ParseException in project orientdb by orientechnologies.
the class OLuceneQueryBuilder method getQueryParser.
protected Query getQueryParser(OIndexDefinition index, String key, Analyzer analyzer) throws ParseException {
String[] fields;
if (index.isAutomatic()) {
fields = index.getFields().toArray(new String[index.getFields().size()]);
} else {
int length = index.getTypes().length;
fields = new String[length];
for (int i = 0; i < length; i++) {
fields[i] = "k" + i;
}
}
Map<String, OType> types = new HashMap<String, OType>();
for (int i = 0; i < fields.length; i++) {
String field = fields[i];
types.put(field, index.getTypes()[i]);
}
// for (Map.Entry<String, OType> typeEntry : types.entrySet()) {
// System.out.println("typeEntry = " + typeEntry);
// }
final OLuceneMultiFieldQueryParser queryParser = new OLuceneMultiFieldQueryParser(types, fields, analyzer);
queryParser.setAllowLeadingWildcard(allowLeadingWildcard);
queryParser.setLowercaseExpandedTerms(lowercaseExpandedTerms);
try {
return queryParser.parse(key);
} catch (org.apache.lucene.queryparser.classic.ParseException e) {
throw new ParseException(e.getMessage());
}
}
use of com.orientechnologies.orient.core.sql.parser.ParseException in project orientdb by orientechnologies.
the class OLuceneFullTextIndexEngine method getInTx.
@Override
public Object getInTx(Object key, OLuceneTxChanges changes) {
try {
Query q = queryBuilder.query(index, key, queryAnalyzer());
OCommandContext context = null;
if (key instanceof OLuceneCompositeKey) {
context = ((OLuceneCompositeKey) key).getContext();
}
return getResults(q, context, key, changes);
} catch (ParseException e) {
throw OException.wrapException(new OIndexEngineException("Error parsing lucene query"), e);
}
}
Aggregations