From EPrints Documentation
Revision as of 18:29, 11 August 2009 by Tdb01r (talk | contribs) (New page: <!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost. -...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


EPrints::Search::Condition - Atomic search condition.


Represents a simple atomic search condition like abstract contains "fish" or date is bigger than 2000.

Can also represent a "AND" or "OR"'d list of sub-conditions, so forming a tree-like data-structure.

Search conditions can be used either to create search results (as a list of id's), or to test if a single object matches the condition.

This module should usually not be used directly. It is used internally by EPrints::Search.


 $scond = EPrints::Search::Condition->new( $op, @params );

Create a new search condition object with the given operation and parameters.


 $scond->copy_from( $scond2 );

Make this search condition the same as $scond2. Used by the optimiser to shuffle things around.


 $desc = $scond->describe

Return a text description of the structure of this search condition tree. Used for debugging.


 $sql_table = $scond->get_table( [ $dataset, $field ] );

Return the name of the actual SQL table which this condition is concerned with.

If dataset and field is defined then uses these rather than the current value for the condition.


 $bool = $scond->is_comparison

Return true if the OP is one of =, >, <, >=, <=


 $bool = $scond->is_control

Return true if the OP is one of AND, OR.


 $bool = $scond->item_matches( $dataobj )

Return true if the given data object matches this search condition.


 @ops = $scond->ordered_ops

AND or OR conditions only. Return the sub conditions ordered by approximate ease. This is used to make sure a TRUE or FALSE is prcessed before an index-lookup, and that everthing else is is tried before a grep OP (which uses LIKE). This means that it can often give up before the expensive operation is needed.


 @ops = $scond->get_op_val

Return a number which roughly relates to how "hard" the OP of this condition is. Used to decide what order to process AND and OR sub-conditions.


 $ids = $scond->process( $session, [$indent], [$filter] );

Return a reference to an array containing the ID's of items in the database which match this condition.

If the search condition matches the whole dataset then it returns ["ALL"] rather than a huge list of ID's.

$indent is only used for debugging code.

$filter is only used in ops of type "grep". It is a reference to an array of ids of items to be greped, so that the grep does not need to be applied to all values in the database.


 @ops = $scond->optimise

Rearrange this condition tree so that it is more optimised.

For example an "OR" where one sub op is "TRUE" can be optimised to just be "TRUE" itself.


Warning These methods were found in the source code but didn't have any POD associated with them. This may be because we haven't got around to documenting them yet or it could be because they are internal to the API and not intended for use by other parts of EPrints.