Rit::Base::Search - Search directly in DB
Represents one search project.
CGI query parameters reserved for use with some methods are:
limit use_cached query remove revprop_... prop_... order_by... path_... replace
These can be called with the class name or any Search object.
Shortcut for $search->result->size
but returns undef if no
search result exist.
Returns a Para::Frame::List
Take care not to try to recalculate the result from search obj if the result is set by other method.
$s->add_stats $s->add_stats($bool)
Gets/sets a boolean value if this search should be added to the statistics using Rit::Base::Resource/log_search.
$search->modify_from_query
Recognized parts are:
revprop rev prop parse remove
remove calls /broaden. Example: [% FOREACH ckey IN crits.keys %] [% NEXT UNLESS ckey == 'departure' %] [% crit = crits.$ckey %] [% FOREACH foo IN crit.prop %] [% hidden("remove", "prop_${foo.key}") %] [% END %] [% END %]
If parse is set to value, the value are parsed recognizing:
value rev arclim clean match prio type scof
Broaden never keeps predor-preds... Bug to fix later...
$search->modify( \%crits ) $search->modify( \%crits, \%args )
%crits
consists of key/value pairs. The values can be an arrayref,
a Rit::Base::List or a single value. For a list, we search for
nodes having at least one of the listed values.
Each value can be a Rit::Base::Resource object, a ref to a hash
containing an id
key or a ref to a hash in the form of a
subrequest. The id will be extracted by calling
Rit::Base::Resource/get_id.
Empty values are valid. (That includes fales values, empty strings and undef values or undef objects.)
The %args
is used for all %crits
.
private: Can be used to hide some properties in the presentation of a search object. clean: Sets the clean property for each criterion. arclim: Only search for nodes where the properties meets the arclim
The keys are built up of parts used to describe the type of search part (search criterion).
The search format should be compatible with Rit::Base::List/find.
currently only used in one place in search/fairs.tt
This type of search may be removed removed in the future
Calls /order_add with the given values.
This functionality may be moved to /modify_from_query.
<rev> _ <pred> _ <arclim> _ <clean> _ <comp> _ <prio>
All parts except pred
is optional.
Example: rev_in_region_explicit_clean_begins_2
Perl does a non-greedy match to extract all the parts from the key.
rev
: rev
indicates a reverse property.
pred
: Any predicate name.
arclim
: Any of Rit::Base::Arc::Lim/limflag. Those are criterions for
the arcs to match. This will override the value of args.arclim
.
Defaults to Rit::Base::Arc/active.
clean
: If clean
, uses the clean version of strings in the
search. This will override the value of args.clean
. Defaults to
false.
comp
: Any of eq
, like
, begins
, gt
, lt
, ne
,
exist
.
prio
: One or more digits.
Returns: 1
$s->execute(\%args)
Args MUST be a hashref.
Get the search object in node form
Transform search to set of PUBLIC explained criterions.
props: push( @{$ecrits->{$pred_name}{'prop'}}, $prop );
$pred_name is in a form equal to the one used in html forms
$prop is the value node
$search->set_arclim( $arclim )
See Rit::Base::Arc::Lim/limflag
$search->arclim
See Rit::Base::Arc::Lim/limflag
$search->set_arclim( $date )
See Rit::Base::Arc::List/arc_active_on_date
$search->arclim_sql $search->arclim_sql( \%args )
Supported args are
arclim prefix
Returns: The sql string to insert, beginning with "and ..."
$search->order_add( ... )
Rit::Base, Rit::Base::Resource, Rit::Base::Arc, Rit::Base::Pred, Rit::Base::List