P4 Search is a tool built internally and open-sourced in the Perforce Workshop. It creates and uses an external search index to allow users to search the content of a Perforce Server. This talk will explain the inner workings of P4 Search, its setup and applications, and explore ideas on how to extend this great and essential tool.
6. #
⢠Built-in command, since Perforce 2010.1
⢠Search files stored in P4D based on content
â Case sensitive and insensitive searches
â Can use regular expressions
â Can search through all revisions
â Provide context search
⢠Returns depot paths
7. #
⢠A few drawbacks:
â Text search only, limited to 4K lines
â No search for Metadata such as attributes
⢠Performance concerns:
â Limited to 10,000 revisions by default
â Memory and CPU consumption
â But: lockless with peeking since 2013.3
8. #
p4 files/p4 fstat
index
store
search
Search engine indexes content
Stores it in its own database
Users search the index first
Index returns a depot path
Index and Perforce Server
can live on separate hosts
9. #
⢠Lucene
â Scalable, high performance indexing
â Search Algorithms
⢠Solr
â Stand-alone enterprise search server
â HTML Administration interface
â Extensible
⢠Tika
â Content analysis tool
10. #
⢠P4Search
â Index queue (processing indexing requests)
â Search controller (security)
â RESTful API (integration into other tools)
â UI (simple searches)
⢠Runs in Jetty
24. #
⢠External index and protection table?
⢠Solution:
â Use a programmable search engine
â Use Perforce protections to filter results
ď¨ Users need read access to files to be able to search
27. #
⢠Download from the Workshop
⢠Follow the provided instructions to install
⢠Run two services
â p4search-solr
â p4search-jetty
28. #
⢠On first run index your entire depot
â You probably donât want to do this
⢠On submit index new file revs
â change-commit trigger on depot location
⢠At any time any given change
â curl POST --data commit,change#
http://p4search:8080/api/queue/{token}
29. #
⢠Indexing
â With trigger P4D, so ultimately any given client and user
⢠Searching
â P4Search UI
â Piper
â Commons
â Custom through P4Search API
30. #
⢠Deep dive after learning Lucene/Solr
⢠Starting point
p4search/solr/example/solr/collection1/conf
â schema.xml
â solrconfig.xml