NAME

Rit::Base::Search - Search directly in DB

DESCRIPTION

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

Constructors

These can be called with the class name or any Search object.

new

Accessors

size

Shortcut for $search->result->size but returns undef if no search result exist.

result

Returns a Para::Frame::List

set_result

Take care not to try to recalculate the result from search obj if the result is set by other method.

reset_result

result_url

form_url

add_stats

  $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.

Public methods

cached_search_result

reset

query_setup

form_setup

modify_from_query

  $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

Broaden never keeps predor-preds... Bug to fix later...

modify

  $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.

path

currently only used in one place in search/fairs.tt

This type of search may be removed removed in the future

order_by

Calls /order_add with the given values.

This functionality may be moved to /modify_from_query.

Main search key format

  <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

execute

  $s->execute(\%args)

Args MUST be a hashref.

node

Get the search object in node form

criterions

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

set_arclim

  $search->set_arclim( $arclim )

See Rit::Base::Arc::Lim/limflag

arclim

  $search->arclim

See Rit::Base::Arc::Lim/limflag

set_arc_active_on_date

  $search->set_arclim( $date )

See Rit::Base::Arc::List/arc_active_on_date

arclim_sql

  $search->arclim_sql

  $search->arclim_sql( \%args )

Supported args are

  arclim
  prefix

Returns: The sql string to insert, beginning with "and ..."

order_add

  $search->order_add( ... )

See Para::Frame::List/sorted

SEE ALSO

Rit::Base, Rit::Base::Resource, Rit::Base::Arc, Rit::Base::Pred, Rit::Base::List