Search

P4 Code Review's search feature combines user, group, project, and file path searching. The standard P4 Code Review searches can be extended to search file content by using the optional P4 Search API.

You can download the P4 Search API installer from the P4 Search download page on the Perforce website. For more information, see the P4 Search Documentation and the P4 Searchrelease notes.

A configuration change only takes effect when the configuration cache has been reloaded. You must be an admin or super user to reload the P4 Code Review config cache.

To reload the configuration:

  1. Open the user menu (top-right corner of P4 Code Review).

  2. Select System Information.

  3. Open the Cache Info tab.

  4. Click Reload Configuration.

If changes to the config.php file might have caused the P4 Code Review web interface to become unresponsive, remove the problematic changes from the config.php file, then clear the configuration cache by running this command: rm -f /opt/perforce/swarm/data/cache/module-config-cache.php

Configure P4 Code Review search with the following configuration block in the SWARM_ROOT/data/config.php file:

<?php
// this block should be a peer of 'p4'
'search' => array(
'maxlocktime' => 5000, // 5 seconds, in milliseconds 'max_scan_rows' => 250000, // maximum rows scanned by fallback file search
'p4_search_host' => 'http://myhelixsearch.mydomain.com:4567', // optional URL to the P4 Search host
),

maxlocktime

The maxlocktime key specifies the maximum amount of time, in milliseconds, that any table within the P4 Server should be locked while performing fstat command searching. Increasing this value might allow better search results at the expense of potentially blocking other queries on the P4 Server. Decreasing this value impacts the P4 Server less, but may be insufficient for returning the desired search results.

max_scan_rows

The max_scan_rows key specifies the maximum number of database rows that P4 Server can scan when P4 Code Review performs file searches using the fallback p4 fstat search method.

The default value is 250000.

When the configured limit is reached, file search results are not returned and users are prompted to narrow the depot path being searched.

Set the value to:

  • A positive integer to enforce a scan limit.

  • 0 to disable the limit.

This setting only applies when:

  • P4 Search is not configured.

  • P4 Code Review is using the fallback p4 fstat search implementation for file searches.

This setting does not affect other P4 Server commands executed by P4 Code Review.

p4_search_host

The p4_search_host configurable specifies the URL of your P4 Search server. When configured, P4 Code Review issues API calls to P4 Search to take advantage of its file content and description indexing.

Search limit reached

If a file search exceeds the configured scan limit, P4 Code Review displays the following message:

This location has too many files to search. Browse to a narrower depot path and try again.

To search a large depot structure, browse to a more specific depot path and then perform the search again.

Comment attachment thumbnail and blur generation

P4 Code Review generates the blur and thumbnail images for P4 Code Review comment attachments and stores them in the comment attachment depot.

To prevent P4 Code Review clashing with P4 Search thumbnail and blur generation, set the P4 Server protections for the P4 Code Review comment attachments depot directory so only the swarm user has access to it.

P4 Code Review 2022.1 Patch 1 and later: By default, the P4 Code Review package post-installation configuration script offers to create the comment attachment depot directory as //.swarm and set the protections so only the swarm user has access to it.

For example, if the comment attachment depot directory is //.swarm, set P4 Server protections for //.swarm to:

list user * * -//.swarm/...

admin user swarm * //.swarm/...

super user super * //.swarm/...

This prevents P4 Search creating thumbnails and blurs for files stored in the comment attachment depot directory.

More information