Class OLuceneSearchMoreLikeThisFunction
java.lang.Object
com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract
com.orientechnologies.lucene.functions.OLuceneSearchMoreLikeThisFunction
- All Implemented Interfaces:
OIndexableSQLFunction,OSQLFunction
public class OLuceneSearchMoreLikeThisFunction
extends OSQLFunctionAbstract
implements OIndexableSQLFunction
Created by frank on 15/01/2017.
-
Field Summary
FieldsFields inherited from class com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract
maxParams, minParams, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsIndexedExecution(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Checks if this function can be used to fetch data from this target and with these arguments (eg. if the index exists on this target and it's defined on these fields)booleancanExecuteInline(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) checks if the function can be used even on single records, not as an indexed function (even if the index does not exist at all)longestimate(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) estimates the number of entries returned by searchFromTarget() with these parametersexecute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] params, OCommandContext ctx) Process a record.getName()Function name, the name is used by the sql parser to identify a call this function.Returns a convenient SQL String representation of the function.searchFromTarget(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) returns all the entries belonging to the target that match the binary condition where this function appearsbooleanshouldExecuteAfterSearch(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Checks if this function should be called even if the methodOIndexableSQLFunction.searchFromTarget(com.orientechnologies.orient.core.sql.parser.OFromClause, com.orientechnologies.orient.core.sql.parser.OBinaryCompareOperator, java.lang.Object, com.orientechnologies.orient.core.command.OCommandContext, com.orientechnologies.orient.core.sql.parser.OExpression...)is executed.Methods inherited from class com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract
aggregateResults, config, filterResult, getDatabase, getDistributedStorageId, getMaxParams, getMinParams, getResult, getSingleItem, getSingleProperty, mergeDistributedResult, returnDistributedResult, setResult, shouldMergeDistributedResult, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.sql.functions.OSQLFunction
aggregateResults, config, filterResult, getMaxParams, getMinParams, getResult, mergeDistributedResult, setResult, shouldMergeDistributedResult
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
OLuceneSearchMoreLikeThisFunction
public OLuceneSearchMoreLikeThisFunction()
-
-
Method Details
-
getName
Description copied from interface:OSQLFunctionFunction name, the name is used by the sql parser to identify a call this function.- Specified by:
getNamein interfaceOSQLFunction- Overrides:
getNamein classOSQLFunctionAbstract- Returns:
- String , function name, never null or empty.
-
execute
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] params, OCommandContext ctx) Description copied from interface:OSQLFunctionProcess a record.- Specified by:
executein interfaceOSQLFunctioniCurrentRecord- : current recordiCurrentResult- TODOparams- : function parameters, number is ensured to be within minParams and maxParams.ctx- : object calling this function- Returns:
- function result, can be null. Special cases : can be null if function aggregate results, can be null if function filter results : this mean result is excluded
-
getSyntax
Description copied from interface:OSQLFunctionReturns a convenient SQL String representation of the function.Example :
myFunction( param1, param2, [optionalParam3])
This text will be used in exception messages.
- Specified by:
getSyntaxin interfaceOSQLFunction- Returns:
- String , never null.
-
searchFromTarget
public Iterable<OIdentifiable> searchFromTarget(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Description copied from interface:OIndexableSQLFunctionreturns all the entries belonging to the target that match the binary condition where this function appears- Specified by:
searchFromTargetin interfaceOIndexableSQLFunction- Parameters:
target- the query targetoperator- the operator after the function, eg. inselect from Foo where myFunction(name) > 4the operator is >rightValue- the value that has to be compared to the function result, eg. inselect from Foo where myFunction(name) > 4the right value is 4ctx- the command context for this queryargs- the function arguments, eg. inselect from Foo where myFunction(name) > 4the arguments are [name]- Returns:
- an iterable of records that match the condition; null means that the execution could not be performed for some reason.
-
estimate
public long estimate(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Description copied from interface:OIndexableSQLFunctionestimates the number of entries returned by searchFromTarget() with these parameters- Specified by:
estimatein interfaceOIndexableSQLFunction- Parameters:
target- the query targetoperator- the operator after the function, eg. inselect from Foo where myFunction(name) > 4the operator is >rightValue- the value that has to be compared to the function result, eg. inselect from Foo where myFunction(name) > 4the right value is 4ctx- the command context for this queryargs- the function arguments, eg. inselect from Foo where myFunction(name) > 4the arguments are [name]- Returns:
- an estimantion of how many entries will be returned by searchFromTarget() with these parameters, -1 if the estimation cannot be done
-
canExecuteInline
public boolean canExecuteInline(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Description copied from interface:OIndexableSQLFunctionchecks if the function can be used even on single records, not as an indexed function (even if the index does not exist at all)- Specified by:
canExecuteInlinein interfaceOIndexableSQLFunction- Parameters:
target- the query targetoperator- the operator after the function, eg. inselect from Foo where myFunction(name) > 4the operator is >rightValue- the value that has to be compared to the function result, eg. inselect from Foo where myFunction(name) > 4the right value is 4ctx- the command context for this queryargs- the function arguments, eg. inselect from Foo where myFunction(name) > 4the arguments are [name]- Returns:
- true if the function can be calculated without the index. False otherwise
-
allowsIndexedExecution
public boolean allowsIndexedExecution(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Description copied from interface:OIndexableSQLFunctionChecks if this function can be used to fetch data from this target and with these arguments (eg. if the index exists on this target and it's defined on these fields)- Specified by:
allowsIndexedExecutionin interfaceOIndexableSQLFunction- Parameters:
target- the query targetoperator- the operator after the function, eg. inselect from Foo where myFunction(name) > 4the operator is >rightValue- the value that has to be compared to the function result, eg. inselect from Foo where myFunction(name) > 4the right value is 4ctx- the command context for this queryargs- the function arguments, eg. inselect from Foo where myFunction(name) > 4the arguments are [name]- Returns:
- True if the function can be used to fetch from an index. False otherwise
-
shouldExecuteAfterSearch
public boolean shouldExecuteAfterSearch(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args) Description copied from interface:OIndexableSQLFunctionChecks if this function should be called even if the methodOIndexableSQLFunction.searchFromTarget(com.orientechnologies.orient.core.sql.parser.OFromClause, com.orientechnologies.orient.core.sql.parser.OBinaryCompareOperator, java.lang.Object, com.orientechnologies.orient.core.command.OCommandContext, com.orientechnologies.orient.core.sql.parser.OExpression...)is executed.- Specified by:
shouldExecuteAfterSearchin interfaceOIndexableSQLFunction- Parameters:
target- the query targetoperator- the operator after the function, eg. inselect from Foo where myFunction(name) > 4the operator is >rightValue- the value that has to be compared to the function result, eg. inselect from Foo where myFunction(name) > 4the right value is 4ctx- the command context for this queryargs- the function arguments, eg. inselect from Foo where myFunction(name) > 4the arguments are [name]- Returns:
- True if this function should be called even if the method
OIndexableSQLFunction.searchFromTarget(com.orientechnologies.orient.core.sql.parser.OFromClause, com.orientechnologies.orient.core.sql.parser.OBinaryCompareOperator, java.lang.Object, com.orientechnologies.orient.core.command.OCommandContext, com.orientechnologies.orient.core.sql.parser.OExpression...)is executed. False otherwise
-