Deprecated Search endpoints
From Helix Search 2021.2, the v1 API endpoints have been deprecated. Support for them will be removed in a future release.
The v1 API endpoints have been replaced by v1.1 API endpoints.
This section details the deprecated v1 endpoints for Helix Search. For information on the current raw search endpoint that replaces the v1 raw search endpoint, see Raw Search Endpoint
Search changes
Description
GET http://localhost:1601/api/v1/search/change
Search for changes matching the search key in any field. Results are sorted by change number in descending order. The first 15 results are returned by default.
Fields
- search: search string
- page: for pagination to access a specific page to render enter page number - optional
Usage example
Search for jenkinsfile and render page 2 of the search results:
curl -u<user>:<YourTicket>: -H "Content-Type: application/json" -X GET "http://localhost:1601/api/v1/search/change?search=jenkinsfile&page=2"
Helix Search responds with:
{ "took": 5, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 9, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-917332", "_score": null, "_source": { "type": "change", "change": 917332, "date": 1566316635000, "client": "bruno_p4perl_ws", "user": "bruno", "restricted": false, "description": "Added CentOS to Jenkinsfile for p4perl.\n", "depotFile": "//depot/main/p4-perl", "indexDate": 1586445668599, "productVersion": "unspecified" }, "sort": [ 917332 ] }, ... } ] } }
Search revisions/files
Description
GET http://localhost:1601/api/v1/search/file
Search for revisions matching the search key in any field. Results are sorted by change number in descending order. The first 15 results are returned by default.
Fields
- search: search string
- page: page number to render- default value is 1
- headrev:
- true only show head revisions
- false show all revisions, defaults to false
Usage example
Search for head revisions containing jenkinsfile:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X GET "http://localhost:1601/api/v1/search/file?search=jenkinsfile&headrev=true"
Helix Search responds with:
cardinality#collapsedResults is the count of head revisions returned and Hits.total is the count before collapsing
{ "took": 6, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 17, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "revision-//depot/main/p4-perl/Jenkinsfile#9", "_score": null, "_source": { "type": "revision", "change": 917333, "depotFile": "//depot/main/p4-perl/Jenkinsfile", "action": "edit", "fileType": "text", "rev": 9, "fileSize": 3669, "digest": "AC229F0D44E684ECA84A14E9DA0D62F0", "indexDate": 1586860198366, "productVersion": "unspecified" }, "fields": { "depotFile.keyword": [ "//depot/main/p4-perl/Jenkinsfile" ] }, "sort": [ 917333 ] }, ... ] }, "aggregations": { "cardinality#collapsedResults": { "value": 2 } } }
Search file content
Description
GET http://localhost:1601/api/v1/search/content
Search through a file revision and file content matching search key. Results are sorted by change number in descending order. The first 15 results are returned by default.
Fields
- search: search string
- page: page number to render- default value is 1
- headrev:
- true only show head revisions or
- false show all revisions - default value
Usage example
Search for files containing pipeline and render page 2 of the search results:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X GET "http://localhost:1601/api/v1/search/content?search=pipeline&page=2"
Helix Search responds with:
{ "took": 3, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 17, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "content-//p4-python/main/Jenkinsfile#2", "_score": null, "_source": { "type": "content", "depotFile": "//p4-python/main/Jenkinsfile", "rev": 2, "change": 793750, "fileName": "Jenkinsfile", "fileSize": 1285, "fileType": "text", "action": "edit", "user": "bruno", "contentType": "text/plain", "content": "pipeline {\n \n\tagent {\n docker {\n image 'p4api-ubuntu1804'\n label 'integ-p4java'\n registryUrl 'https://p4hive.helixcore.cloud'\n }\n\t}\n\t\n\toptions {\n\t skipDefaultCheckout()\n\t} \n\t\n\tstages {\n\t stage('Checkout') { \n\t steps {\n checkout perforce(credential: 'bot', populate: autoClean(delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', threads: '4'], pin: '', quiet: true, replace: true, tidy: false), workspace: manualSpec(charset: 'none', cleanup: false, name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: true, changeView: '', clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/main/p4-python/... //${P4_CLIENT}/...')))\n\t }\n\t }\n\t\tstage('Compile') { \n steps {\n withEnv(['HOME=/home/build/workspace/p4python']) {\n sh 'env'\n sh 'sed -i \"s/2019\\\\.1/2019.2/\" setup.py'\n sh 'python setup.py build --apidir=/p4/ws/p4api --ssl=/p4/ws/lib'\n sh 'python p4test.py'\n }\n }\n\t\t}\n\t}\n}\n\n", "indexDate": 1586860204463, "productVersion": "unspecified" }, "sort": [ 793750 ] }, ... ] } }
Raw Search Endpoint
Description
POST http://localhost:1601/api/v1/search/raw
Enables you to search Elasticsearch directly. Returns results as received from Elasticsearch, see the detailed Helix Search: Data model to form your Elasticsearch queries.
Fields
query: Elasticsearch raw query.
Usage example
Submitted changes query
Sorted by change in descending order:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } } ], "filter": { "bool": { "must": [ { "term": { "type": "change" } } ] } } } }, "size": 3, "from": 0, "sort": [ { "change": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 25, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 847, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-917338", "_score": null, "_source": { "date": 1569577884000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342404753, "change": 917338, "client": "bruno.p4-perl", "description": "Remove old release notes and use client mapping to overlay p4perlnotes.txt\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bruno" }, "sort": [ 917338 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917337", "_score": null, "_source": { "date": 1568639867000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342399216, "change": 917337, "client": "bruno.p4-perl", "description": "Update Installer UX version to 5.30\n", "depotFile": "//depot/main/p4-perl/packaging/win/installer", "type": "change", "user": "bruno" }, "sort": [ 917337 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917336", "_score": null, "_source": { "date": 1568633257000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342412052, "change": 917336, "client": "bruno.p4-perl", "description": "Fix path issues and remove Perl version from Setut.vcxproj so that EC can add the full version syntax on copy to p4-bin.\n", "depotFile": "//depot/main/p4-perl/packaging/win/setup", "type": "change", "user": "bruno" }, "sort": [ 917336 ] } ] } }
Submitted changes query
Sorted by change in ascending order:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "change", "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } } ], "filter": { "bool": { "must": [ { "term": { "type": "change" } }, { "wildcard": { "depotFile.tree": "//depot/main/p4-perl" } } ] } } } }, "size": 3, "from": 0, "sort": [ { "user.keyword": { "order": "asc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 8, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 256, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-917218", "_score": null, "_source": { "date": 1326931523000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342408753, "change": 917218, "client": "bob-mac", "description": "Force building against the SSL Stub library shipped with the \np4api distributionfor the build.\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bob" }, "sort": [ "bob" ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917328", "_score": null, "_source": { "date": 1566290570000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342403949, "change": 917328, "client": "bill_p4perl", "description": "Changed api version to 2019.1\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bill" }, "sort": [ "bill" ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917331", "_score": null, "_source": { "date": 1566300456000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342409546, "change": 917331, "client": "bill_p4perl", "description": "Specs changed as per 19.1\n", "depotFile": "//depot/main/p4-perl/lib", "type": "change", "user": "bill" }, "sort": [ "bill" ] } ] } }
Submitted changes query
Sorted by date in descending order for an exact user:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "change", "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } }, { "match": { "user": { "query": "bruno" } } } ], "filter": { "bool": { "must": [ { "term": { "type": "change" } } ] } } } }, "size": 10, "from": 0, "sort": [ { "date": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 7, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 126, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-793805", "_score": null, "_source": { "date": 1569591609000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342439643, "change": 793805, "client": "bruno.github.p4python.ws", "description": "Cleaned up files for GitHib release\n", "depotFile": "//p4-python/main", "type": "change", "user": "bruno" }, "sort": [ 1569591609000 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917338", "_score": null, "_source": { "date": 1569577884000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342404753, "change": 917338, "client": "bruno.p4-perl", "description": "Remove old 2016 release notes and use client mapping to overlay p4perlnotes.txt\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bruno" }, "sort": [ 1569577884000 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-793804", "_score": null, "_source": { "date": 1569424904000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342440195, "change": 793804, "client": "bruno.p4-python", "description": "Merging using bruno.p4python.main>p\n", "depotFile": "//p4-python/main/...", "type": "change", "user": "bruno" }, "sort": [ 1569424904000 ] } ] } }
Submitted changes query
Sorted by date in descending order with wildcard user search:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "change", "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } }, { "wildcard": { "user": { "value": "p*", "boost": 1, "rewrite": "constant_score" } } } ], "filter": { "bool": { "must": [ { "term": { "type": "change" } } ] } } } }, "size": 3, "from": 0, "sort": [ { "date": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 7, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 150, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-793805", "_score": null, "_source": { "date": 1569591609000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342439643, "change": 793805, "client": "bruno.github.p4python.ws", "description": "Cleaned up files for GitHib release\n", "depotFile": "//p4-python/main", "type": "change", "user": "bruno" }, "sort": [ 1569591609000 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917338", "_score": null, "_source": { "date": 1569577884000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342404753, "change": 917338, "client": "bruno.p4-perl", "description": "Remove old 2016 release notes and use client mapping to overlay p4perlnotes.txt\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bruno" }, "sort": [ 1569577884000 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-793804", "_score": null, "_source": { "date": 1569424904000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342440195, "change": 793804, "client": "bruno.p4-python", "description": "Merging using bruno.p4python.main>p\n", "depotFile": "//p4-python/main/...", "type": "change", "user": "bruno" }, "sort": [ 1569424904000 ] } ] } }
Submitted changes query
Sorted by change in descending order with date range search:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "change", "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } }, { "range": { "date": { "from": 1568198400000, "to": 1581421200000, "include_lower": true, "include_upper": true, "format": "epoch_millis", "boost": 1 } } } ], "filter": { "bool": { "must": [ { "term": { "type": "change" } } ] } } } }, "size": 3, "from": 0, "sort": [ { "change": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 4, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 16, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "change-917338", "_score": null, "_source": { "date": 1569577884000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342404753, "change": 917338, "client": "bruno.p4-perl", "description": "Remove old 2016 release notes and use client mapping to overlay p4perlnotes.txt\n", "depotFile": "//depot/main/p4-perl", "type": "change", "user": "bruno" }, "sort": [ 917338 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917337", "_score": null, "_source": { "date": 1568639867000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342399216, "change": 917337, "client": "bruno.p4-perl", "description": "Update Installer UX Perl version to 5.30\n", "depotFile": "//depot/main/p4-perl/packaging/win/installer", "type": "change", "user": "bruno" }, "sort": [ 917337 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "change-917336", "_score": null, "_source": { "date": 1568633257000, "productVersion": "unspecified", "restricted": false, "indexDate": 1604342412052, "change": 917336, "client": "bruno.p4-perl", "description": "Fix path issues and remove Perl version from Setut.vcxproj so that EC can add the full version syntax on copy to p4-bin.\n", "depotFile": "//depot/main/p4-perl/packaging/win/setup", "type": "change", "user": "bruno" }, "sort": [ 917336 ] } ] } }
File revision query
Sorted by change in descending order, with wildcard sort for depotFile:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } } ], "filter": { "bool": { "must": [ { "term": { "type": "revision" } }, { "wildcard": { "depotFile.tree": "//depot/main/p4-perl/packaging/win/*/product.wxs" } } ] } } } }, "collapse": { "field": "depotFile.keyword" }, "aggs": { "totalCollapsed": { "cardinality": { "field": "depotFile.keyword" } } }, "size": 3, "from": 0, "sort": [ { "change": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 6, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 11, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "revision-//depot/main/p4-perl/packaging/win/installer/product.wxs#11", "_score": null, "_source": { "rev": 11, "productVersion": "unspecified", "fileSize": 18521, "indexDate": 1604342399216, "change": 917337, "digest": "12D89059BB61FBECA4A37D100B704813", "depotFile": "//depot/main/p4-perl/packaging/win/installer/product.wxs", "action": "edit", "type": "revision", "fileType": "utf8" }, "sort": [ 917337 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "revision-//depot/main/p4-perl/packaging/win/installer/product.wxs#10", "_score": null, "_source": { "rev": 10, "productVersion": "unspecified", "fileSize": 18521, "indexDate": 1604342407648, "change": 917318, "digest": "A7C6C0544A5C42CA022A017F034E698B", "depotFile": "//depot/main/p4-perl/packaging/win/installer/product.wxs", "action": "edit", "type": "revision", "fileType": "utf8" }, "sort": [ 917318 ] }, { "_index": "perforce1", "_type": "_doc", "_id": "revision-//depot/main/p4-perl/packaging/win/installer/product.wxs#9", "_score": null, "_source": { "rev": 9, "productVersion": "unspecified", "fileSize": 18439, "indexDate": 1604342402352, "change": 917316, "digest": "9D787128B84EF86B420BE957F376078C", "depotFile": "//depot/main/p4-perl/packaging/win/installer/product.wxs", "action": "edit", "type": "revision", "fileType": "utf8" }, "sort": [ 917316 ] } ] } }
File revision query
Sorted by change in descending order, with wildcard search for depotFile, and headRev set to true:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "revision", "headRev": true, "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } } ], "filter": { "bool": { "must": [ { "term": { "type": "revision" } }, { "wildcard": { "depotFile.tree": "//depot/main/p4-perl/packaging/win/*/product.wxs" } } ] } } } }, "collapse": { "field": "depotFile.keyword" }, "aggs": { "totalCollapsed": { "cardinality": { "field": "depotFile.keyword" } } }, "size": 3, "from": 0, "sort": [ { "change": { "order": "desc", "unmapped_type": "long" } } ] }
For aggregations, one record returns:
{ "took": 6, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 11, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "revision-//depot/main/p4-perl/packaging/win/installer/product.wxs#11", "_score": null, "_source": { "rev": 11, "productVersion": "unspecified", "fileSize": 18521, "indexDate": 1604342399216, "change": 917337, "digest": "12D89059BB61FBECA4A37D100B704813", "depotFile": "//depot/main/p4-perl/packaging/win/installer/product.wxs", "action": "edit", "type": "revision", "fileType": "utf8" }, "fields": { "depotFile.keyword": [ "//depot/main/p4-perl/packaging/win/installer/product.wxs" ] }, "sort": [ 917337 ] } ] }, "aggregations": { "cardinality#depotFile.keyword": { "value": 1 } } }
File Content Query
Sort by fileName in descending order, with wildcard search for depotFile, and headRev set to true:
curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\ { "queryType": "content", "headRev": true, "query": { "bool": { "must": [ { "multi_match": { "query": "p4" } } ], "filter": { "bool": { "must": [ { "term": { "type": "content" } }, { "wildcard": { "depotFile.tree": "//depot/main/p4-perl/packaging/win/setup*" } } ] } } } }, "collapse": { "field": "depotFile.keyword" }, "aggs": { "totalCollapsed": { "cardinality": { "field": "depotFile.keyword" } } }, "size": 3, "from": 0, "sort": [ { "fileName.keyword": { "order": "desc", "unmapped_type": "long" } } ] }
Elasticsearch responds with:
{ "took": 5, "timed_out": false, "terminated_early": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 17, "relation": "eq" }, "max_score": null, "hits": [ { "_index": "perforce1", "_type": "_doc", "_id": "content-//depot/main/p4-perl/packaging/win/setup/targetver.h#1", "_score": null, "_source": { "rev": 1, "fileName": "targetver.h", "productVersion": "unspecified", "fileSize": 306, "indexDate": 1604342555152, "change": 917303, "depotFile": "//depot/main/p4-perl/packaging/win/setup/targetver.h", "action": "add", "type": "content", "user": "kmackey", "contentType": "text/x-chdr", "fileType": "text" }, "fields": { "depotFile.keyword": [ "//depot/main/p4-perl/packaging/win/setup/targetver.h" ] }, "sort": [ "targetver.h" ] }, { "_index": "perforce1", "_type": "_doc", "_id": "content-//depot/main/p4-perl/packaging/win/setup/stdafx.h#1", "_score": null, "_source": { "rev": 1, "fileName": "stdafx.h", "productVersion": "unspecified", "fileSize": 305, "indexDate": 1604342554807, "change": 917303, "depotFile": "//depot/main/p4-perl/packaging/win/setup/stdafx.h", "action": "add", "type": "content", "user": "kmackey", "contentType": "text/x-chdr", "fileType": "text" }, "fields": { "depotFile.keyword": [ "//depot/main/p4-perl/packaging/win/setup/stdafx.h" ] }, "sort": [ "stdafx.h" ] }, { "_index": "perforce1", "_type": "_doc", "_id": "content-//depot/main/p4-perl/packaging/win/setup/stdafx.cpp#1", "_score": null, "_source": { "rev": 1, "fileName": "stdafx.cpp", "productVersion": "unspecified", "fileSize": 284, "indexDate": 1604342554589, "change": 917303, "depotFile": "//depot/main/p4-perl/packaging/win/setup/stdafx.cpp", "action": "add", "type": "content", "user": "kmackey", "contentType": "text/x-c++src", "fileType": "text" }, "fields": { "depotFile.keyword": [ "//depot/main/p4-perl/packaging/win/setup/stdafx.cpp" ] }, "sort": [ "stdafx.cpp" ] } ] }, "aggregations": { "cardinality#depotFile.keyword": { "value": 8 } } }