Part 7: Search

Perform a simple synchronous search.

Now that you have data in a case, you can search it. As part of a search, you can specify a Default metadata profile to use. This will return the fields Name, File Type, and File Path for each item. Note that you can also limit the number of results returned using the request parameter numberOfRecordsRequested. In this example, only 5 results return at a time. The total number of hits was 364 as noted by the count field in the response.

curl --location --request GET 'http://localhost:8080/nuix-restful-service/svc/v2/cases/43b070164ce8453ca30ed9e2dfcce67b/search?query=*&metadataProfile=Default&numberOfRecordsRequested=5' \
--header 'nuix-auth-token: 9729a460-eda7-48dc-ba70-d12b3aae3c8d'
{
    "request": {
        "caseId": "43b070164ce8453ca30ed9e2dfcce67b",
            "query": "*",
            "sortField": null,
            "sortOrder": null,
            "startIndex": 0,
            "numberOfRecordsRequested": 5,
            "deduplicate": null,
            "metadataProfile": "Default",
            "fieldList": null,
            "customMetadataList": null,
            "propertyList": null,
            "itemParameterizedFields": null,
            "showAvailableThumbnails": false,
            "useCache": false,
            "forceCacheDelete": false,
            "searchRetry": 0,
            "relationType": null,
            "entities": [],
            "p": 5,
            "s": 0,
            "customMetadataField": null,
            "field": null,
            "property": null
    },
    "startedOn": 1612985518529,
        "completedOn": 1612985518552,
        "elapsedTimeForSearch": 17,
        "elapsedTimeForSort": 0,
        "elapsedTimeForMarshal": 2,
        "elapsedTimeForDeduplicate": 0,
        "elapsedTotal": 23,
        "metadataItems": [
        "Name",
        "File Type",
        "Path Name"
    ],
        "localizedMetadataItems": [
        "Name",
        "File Type",
        "Path Name"
    ],
        "metadataItemDetails": [
        {
            "name": "Name",
            "localisedName": "Name",
            "type": "String"
        },
        {
            "name": "File Type",
            "localisedName": "File Type",
            "type": "String"
        },
        {
            "name": "Path Name",
            "localisedName": "Path Name",
            "type": "String"
        }
    ],
        "resultList": [
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "allclasses.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "4350a26e-0582-4cdd-8903-feb2454b66ad"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "allclasses-index.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "48fdd676-ecdf-4271-8fb0-a312570888a5"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "allpackages-index.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "b5d26466-0b5f-4b01-bc2e-7ebe6c6d3294"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "index.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "8bc28b97-6d5a-4755-8066-4fa2102705de"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "constant-values.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "ee4cb26f-30b5-4a76-8789-dfbd7fdecf65"
        }
    ],
        "count": 364,
        "deduplicatedCount": 364
}

Alternatively, you can use the following example scripts to perform a search.


import requests
import json

token="YOURTOKEN"
caseId="CASEID"

base_url = "{{host}}:8080/nuix-restful-service/svc"
headers = {
    "Content-Type":"application/json",
    "nuix-auth-token":token
}

params = {
    "query":"*",
    "metadataProfile":"Default",
    "numberOfRecordsRequested":"100",
}

def search():
    try:
        result = requests.get(base_url+"/v2/cases/{}/search".format(caseId), params=params, headers=headers)
        print("Search completed and found {} hits".format(result.json()['count']))
    except Exception as e:
        print(e)


search()

import requests
import json

token="YOURTOKEN"
caseId="CASEID"

base_url = "{{host}}:8080/nuix-restful-service/svc"
headers = {
    "Content-Type":"application/json",
    "Authorization": "Bearer {}".format(token)
}

params = {
    "query":"*",
    "metadataProfile":"Default",
    "numberOfRecordsRequested":"100",
}

def search():
    try:
        result = requests.get(base_url+"/v2/cases/{}/search".format(caseId), params=params, headers=headers)
        print("Search completed and found {} hits".format(result.json()['count']))
    except Exception as e:
        print(e)


search()

Paging

When you limit the numberOfRecordsRequested field, you need to page the result list. To get the next page of results, set the startIndex request paramter equal to 5. Now you can retrieve the next 5 results.

curl --location --request GET 'http://localhost:8080/nuix-restful-service/svc/v2/cases/43b070164ce8453ca30ed9e2dfcce67b/search?query=*&metadataProfile=Default&numberOfRecordsRequested=5&startIndex=5' \
--header 'nuix-auth-token: 9729a460-eda7-48dc-ba70-d12b3aae3c8d'
{
    "request": {
        "caseId": "43b070164ce8453ca30ed9e2dfcce67b",
        "query": "*",
        "sortField": null,
        "sortOrder": null,
        "startIndex": 5,
        "numberOfRecordsRequested": 5,
        "deduplicate": null,
        "metadataProfile": "Default",
        "fieldList": null,
        "customMetadataList": null,
        "propertyList": null,
        "itemParameterizedFields": null,
        "showAvailableThumbnails": false,
        "useCache": false,
        "forceCacheDelete": false,
        "searchRetry": 0,
        "relationType": null,
        "entities": [],
        "p": 5,
        "s": 5,
        "customMetadataField": null,
        "field": null,
        "property": null
    },
    "startedOn": 1612985803142,
    "completedOn": 1612985803161,
    "elapsedTimeForSearch": 13,
    "elapsedTimeForSort": 0,
    "elapsedTimeForMarshal": 2,
    "elapsedTimeForDeduplicate": 0,
    "elapsedTotal": 19,
    "metadataItems": [
        "Name",
        "File Type",
        "Path Name"
    ],
    "localizedMetadataItems": [
        "Name",
        "File Type",
        "Path Name"
    ],
    "metadataItemDetails": [
        {
            "name": "Name",
            "localisedName": "Name",
            "type": "String"
        },
        {
            "name": "File Type",
            "localisedName": "File Type",
            "type": "String"
        },
        {
            "name": "Path Name",
            "localisedName": "Path Name",
            "type": "String"
        }
    ],
    "resultList": [
        {
            "File Type": "Ini Style Configuration File",
            "Name": "member-search-index.js",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "a5ee8532-868e-4abf-bc74-c066e82f234a"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "deprecated-list.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "be263fae-48e5-4c3f-bcd1-3c354960173b"
        },
        {
            "File Type": "JSON Data File",
            "Name": "member-search-index.json",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api/member-search-index.zip",
            "guid": "ae36f963-93c6-43b4-b359-70f9e937d197"
        },
        {
            "File Type": "Plain Text",
            "Name": "element-list",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "a6230532-2bff-445a-9fa3-9a683dcbaadc"
        },
        {
            "File Type": "Hypertext Markup Language Document",
            "Name": "overview-summary.html",
            "Path Name": "/d29719c8-517e-48cb-9fd6-983dd2d6671b/doc/api",
            "guid": "d5ead71c-08ac-49f9-a27c-ee2257706c63"
        }
    ],
    "count": 364,
    "deduplicatedCount": 364
}