Difference between revisions of "API:EPrints/Search/Condition"

From EPrints Documentation
Jump to: navigation, search
(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. -...)
 
(Removing all content from page)
 
Line 1: Line 1:
<!-- 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.
 
-->{{Pod2Wiki}}{{API:Source|file=EPrints/Search/Condition.pm|package_name=EPrints::Search::Condition}}[[Category:API|Condition]]<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::Search::Condition''' - Atomic search condition.
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
 
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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new -->==new==
 
 
  $scond = EPrints::Search::Condition-&gt;new( $op, @params );
 
 
Create a new search condition object with the given operation and parameters.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_copy_from -->==copy_from==
 
 
  $scond-&gt;copy_from( $scond2 );
 
 
Make this search condition the same as $scond2. Used by the optimiser to shuffle things around.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_describe -->==describe==
 
 
  $desc = $scond-&gt;describe
 
 
Return a text description of the structure of this search condition tree. Used for debugging.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_table -->==get_table==
 
 
  $sql_table = $scond-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_comparison -->==is_comparison==
 
 
  $bool = $scond-&gt;is_comparison
 
 
Return true if the OP is one of =, &gt;, &lt;, &gt;=, &lt;=
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_control -->==is_control==
 
 
  $bool = $scond-&gt;is_control
 
 
Return true if the OP is one of AND, OR.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_item_matches -->==item_matches==
 
 
  $bool = $scond-&gt;item_matches( $dataobj )
 
 
Return true if the given data object matches this search condition.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_ordered_ops -->==ordered_ops==
 
 
  @ops = $scond-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_op_val -->==get_op_val==
 
 
  @ops = $scond-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_process -->==process==
 
 
  $ids = $scond-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_optimise -->==optimise==
 
 
  @ops = $scond-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_tables -->==get_tables==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_run_tables -->==run_tables==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
 

Latest revision as of 15:41, 12 August 2009