webCOMAND

search::default_rules()

Return an associative array that defines the default search rules, which can then be customized and passed to search().

Prototype

array default_rules()

Example

Get and display the default rules associative array.

// Perform a simple keyword search on the entire repository.
$rules = \io_comand_search\search::default_rules();
print_r($rules);
$rules['match']['fields'][] = 'Title';
$rules = array_merge_recursive($rules, [
    'Match on Title and Description' => 
        'fields' => ['Title', '.Description()'],
        'keyword' => [
            'matches_title' => [
                'where' => function($vars) { return $vars['field'] . ' ILIKE ' . $vars['keyword_like_filter']; },
                'condition' => function($vars) { return $vars['field'] . ' ILIKE ' . $vars['keyword_like_filter']; },
                'score' => function($vars) { return 1; },
                'weight' => function($vars) { return 100; }
            ]
        ]
    ]
]);
$repo = comand::repo();
$results = \io_comand_search\search::search($repo, "test", [
    'rules' => $rules
]);