August 6, 2014

Mastering Your Universe with P4Search

Healthcare
MERGE User Conference

The Perforce Server, P4D, provides a handy command, “p4 grep”, to let you search through the stored content on the server. With this command, you can answer questions like:

  • Which other parts of the code call my method I am about to refactor?
  • Where does this error message come from?
  • Are there any header files without a copyright notice?

There are some situations where “p4 grep” is limited, though.

Text Files Only

“p4 grep” only deals with text files. This is not a limitation if you are searching through source code (which tends to be text). P4D, however, can store all kinds of binary files as well, such as Office documents.

Wouldn’t it be great to be able to find that presentation or report you wrote a few years ago—especially when you can’t remember its name or where you saved it to?

Thankfully there is a way to search through a much wider range of files.

Indexed Search

Have you ever used Spotlight on a Mac or its equivalent on Windows? Did you notice how quickly it found those documents despite your rather full multi-terabyte drive? That’s the magic of a search index!

“p4 grep” is very fast, but it still has to scan each archive file every time you run the command, which is why it is by default limited to 10,000 revisions for each search.

An external search index can deliver your search results much faster without using any P4D resources, so it does not have to be limited.

Metadata Search

You can attach additional metadata to any file stored in P4D using attributes, which are invisible to “p4 grep”.

An external search index can go beyond the document itself, allowing you to store and search for additional information about your files.

P4Search

Because of the limitations of “p4grep,” we created P4Search using the popular and powerful Solr index based on Apache Lucene. P4Search is a freely available application like Perforce Commons and Perforce Swarm that allows users to index and search through a wide range of documents and their attributes stored in P4D.

Want to learn more? I'll be speaking at MERGE 2014, the Perforce Conference in San Francisco in September. Register for the conference to hear my talk about the implementation, API and use cases of P4Search, as well 50 other sessions!