Search endpoint

This section details the raw search endpoint for Helix Search.

Raw Search Endpoint

Description

POST http://localhost:1601/api/v1.2/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.

Authentication

Supports basic authentication and bearer token authentication, see API authentication.

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 '{\
{
  "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 '{\
{
  "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 '{\
{
  "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 '{\
{
  "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 only showing head revisions:

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"
      }
    }
  ]
}

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 only showing head revisions:

curl -u<user>:<YourTicket> -H "Content-Type: application/json" -X POST -d '{\
{
  "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
    }
  }
}