Class OLuceneSearchOnClassFunction

All Implemented Interfaces:
OIndexableSQLFunction, OSQLFunction

public class OLuceneSearchOnClassFunction extends OLuceneSearchFunctionTemplate
Created by frank on 15/01/2017.
  • Field Details

  • Constructor Details

    • OLuceneSearchOnClassFunction

      public OLuceneSearchOnClassFunction()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: OSQLFunction
      Function name, the name is used by the sql parser to identify a call this function.
      Specified by:
      getName in interface OSQLFunction
      Overrides:
      getName in class OSQLFunctionAbstract
      Returns:
      String , function name, never null or empty.
    • canExecuteInline

      public boolean canExecuteInline(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args)
      Description copied from interface: OIndexableSQLFunction
      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)
      Specified by:
      canExecuteInline in interface OIndexableSQLFunction
      Overrides:
      canExecuteInline in class OLuceneSearchFunctionTemplate
      Parameters:
      target - the query target
      operator - the operator after the function, eg. in select from Foo where myFunction(name) > 4 the operator is >
      rightValue - the value that has to be compared to the function result, eg. in select from Foo where myFunction(name) > 4 the right value is 4
      ctx - the command context for this query
      args - the function arguments, eg. in select from Foo where myFunction(name) > 4 the arguments are [name]
      Returns:
      true if the function can be calculated without the index. False otherwise
    • execute

      public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] params, OCommandContext ctx)
      Description copied from interface: OSQLFunction
      Process a record.
      iCurrentRecord - : current record
      iCurrentResult - TODO
      params - : 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

      public String getSyntax()
      Description copied from interface: OSQLFunction
      Returns a convenient SQL String representation of the function.

      Example :

        myFunction( param1, param2, [optionalParam3])
       

      This text will be used in exception messages.

      Returns:
      String , never null.
    • filterResult

      public boolean filterResult()
      Description copied from interface: OSQLFunction
      A function can act both as transformation or filtering records. If the function may reduce the number final records than it must return true.

      Function should return null for the execute method if the record must be excluded.

      Specified by:
      filterResult in interface OSQLFunction
      Overrides:
      filterResult in class OSQLFunctionAbstract
      Returns:
      true if the function acts as a record filter.
    • searchFromTarget

      public Iterable<OIdentifiable> searchFromTarget(OFromClause target, OBinaryCompareOperator operator, Object rightValue, OCommandContext ctx, OExpression... args)
      Description copied from interface: OIndexableSQLFunction
      returns all the entries belonging to the target that match the binary condition where this function appears
      Parameters:
      target - the query target
      operator - the operator after the function, eg. in select from Foo where myFunction(name) > 4 the operator is >
      rightValue - the value that has to be compared to the function result, eg. in select from Foo where myFunction(name) > 4 the right value is 4
      ctx - the command context for this query
      args - the function arguments, eg. in select from Foo where myFunction(name) > 4 the arguments are [name]
      Returns:
      an iterable of records that match the condition; null means that the execution could not be performed for some reason.
    • searchForIndex

      protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args)
      Specified by:
      searchForIndex in class OLuceneSearchFunctionTemplate