Part 11: Tagging
3 minute read
Tagging
You can now tag some items in the case. For this example, you will tag all files with an HTML file extension. Additionally, you will exclude duplicates, so you need to use the item set you created in the Item Sets and Deduplication part of this tutorial.
curl --location --request POST 'http://localhost:8080/nuix-restful-service/svc/v2/cases/43b070164ce8453ca30ed9e2dfcce67b/itemTags' \
--header 'nuix-auth-token: 9729a460-eda7-48dc-ba70-d12b3aae3c8d' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
"query": "item-set-originals:HelloItemSet AND file-extension:html",
"tagList": [
"HTMLFiles"
]
}'
{
"tagList": [
"HTMLFiles"
],
"successfulTags": [
"HTMLFiles"
],
"failedTags": []
}
Alternatively, you can use the following example script to tag some items in a case.
import requests
import json
caseId="YOUR_CASE_ID"
itemGuid="YOUR_ITEM_GUID"
tagName="sampleTag"
base_url = "http://{{HOST}}:8080/nuix-restful-service/svc"
headers = {
"Content-Type":"application/json",
"nuix-auth-token":"TOKEN"}
def tagItem():
try:
response = requests.put(base_url + "/cases/{caseId}/items/{itemGuid}/tags/{tagName}".format(caseId=caseId,itemGuid=itemGuid,tagName=tagName), headers=headers)
print("Successful tagged an Item: {}".format(response.json()))
except Exception as e:
print(e)
tagItem()
import requests
import json
caseId="YOUR_CASE_ID"
itemGuid="YOUR_ITEM_GUID"
tagName="sampleTag"
base_url = "http://{{HOST}}:8080/nuix-restful-service/svc"
headers = {
"Content-Type":"application/json",
"nuix-auth-token":"TOKEN"}
def tagItem():
try:
response = requests.put(base_url + "/cases/{caseId}/items/{itemGuid}/tags/{tagName}".format(caseId=caseId,itemGuid=itemGuid,tagName=tagName), headers=headers)
print("Successful tagged an Item: {}".format(response.json()))
except Exception as e:
print(e)
tagItem()
Tag Verification
Use a simple synchronous search to verify the items that you tagged. You will use the query tag:HTMLFiles
. In this example, you can see that the search returned 302 results.
curl --location --request GET 'http://localhost:8080/nuix-restful-service/svc/v2/cases/43b070164ce8453ca30ed9e2dfcce67b/search?query=tag:HTMLFiles&metadataProfile=Default&numberOfRecordsRequested=5' \
--header 'nuix-auth-token: 9729a460-eda7-48dc-ba70-d12b3aae3c8d'
{
"request": {
"caseId": "43b070164ce8453ca30ed9e2dfcce67b",
"query": "tag:HTMLFiles",
"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": 1612986781150,
"completedOn": 1612986781172,
"elapsedTimeForSearch": 16,
"elapsedTimeForSort": 0,
"elapsedTimeForMarshal": 2,
"elapsedTimeForDeduplicate": 0,
"elapsedTotal": 22,
"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": 302,
"deduplicatedCount": 302
}
Counting Tags
Instead of using search, you can verify how many items you have tagged using the count endpoint. In this example, the response verifies that you have tagged 302 HTML files.
curl --location --request POST 'http://localhost:8080/nuix-restful-service/svc/v1/cases/43b070164ce8453ca30ed9e2dfcce67b/count' \
--header 'nuix-auth-token: 9729a460-eda7-48dc-ba70-d12b3aae3c8d'
--header 'Content-Type: application/json' \
--data-raw '{
"query": "tag:HTMLFiles"
}'
{
"count": 302,
"query": "tag:HTMLFiles",
"casePath": "/Cases/HelloWorld",
"caseGuid": "43b070164ce8453ca30ed9e2dfcce67b"
}
Feedback
Was this page helpful?
Thank you for your feedback.
Thank you for your feedback.