Attachments
For this test, we have prepared a project with one task and one attachment:
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{ "single": { "id": 1, "class": "Project", "url_path": "\/projects\/1", "name": "Test Project", "completed_on": null, "completed_by_id": null, "is_completed": false, "members": [ 1 ], "category_id": 0, "label_id": 0, "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164954, "updated_by_id": 1, "body": null, "body_formatted": "", "company_id": 1, "leader_id": 1, "currency_id": 2, "template_id": 0, "based_on_type": null, "based_on_id": null, "email": "notifications+m2p-FbhcEwH@mail.manageprojects.com", "is_tracking_enabled": true, "is_client_reporting_enabled": false, "budget": null, "count_tasks": 1, "count_discussions": 0, "count_files": 0, "count_notes": 0 }, "category": null, "hourly_rates": { "1": 100 }, "label_ids": [], "task_lists": null }
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
{ "single": { "id": 1, "class": "Task", "url_path": "\/projects\/1\/tasks\/1", "name": "Visiting Montenegro", "assignee_id": 0, "delegated_by_id": 0, "completed_on": null, "completed_by_id": null, "is_completed": false, "comments_count": 1, "attachments": [], "labels": [], "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "project_id": 1, "is_hidden_from_clients": false, "body": "", "body_formatted": "", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164954, "updated_by_id": 1, "task_number": 1, "task_list_id": 0, "position": 1, "is_important": false, "due_on": null, "estimate": 0, "job_type_id": 0, "total_subtasks": 0, "completed_subtasks": 0, "open_subtasks": 0 }, "subscribers": [ 1 ], "comments": [ { "id": 1, "class": "Comment", "url_path": "\/comments\/1", "attachments": [], "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "parent_type": "Task", "parent_id": 1, "body": "Comment body", "body_formatted": "Comment body", "body_plain_text": "Comment body", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164954, "updated_by_id": 1 } ], "reminders": [], "subtasks": [], "task_list": null, "tracked_time": 0, "tracked_expenses": 0 }
Lets search a bit. First term that we'll search for will find the task because we have it in the task name:
Query Parameters:
1 2 3
{ "q": "montenegro" }
Response:
1
[]
Second search will search for a file name of one of the uploaded files:
Query Parameters:
1 2 3
{ "q": "durmitor.txt" }
Response:
1
[]
Third and fourth requests will search for a term that is mentioned in the files:
Query Parameters:
1 2 3
{ "q": "kosanica" }
Response:
1
[]
Query Parameters:
1 2 3
{ "q": "elastica" }
Response:
1
[]
As we can see, two terms that are mentioned in the uploaded files are not found. Reason why is because we did not attach them to elements that search indexes. Lets do that now:
Payload:
1 2 3 4 5
{ "attach_uploaded_files": [ "vkdr4y5vwG2tzmh0cCROlnFOEgQaUbkXsclmxITn" ] }
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
{ "single": { "id": 1, "class": "Task", "url_path": "\/projects\/1\/tasks\/1", "name": "Visiting Montenegro", "assignee_id": 0, "delegated_by_id": 0, "completed_on": null, "completed_by_id": null, "is_completed": false, "comments_count": 1, "attachments": [ { "id": 1, "name": "durmitor.txt", "mime_type": "text\/plain", "size": 95, "disposition": "attachment", "thumbnail_url": "http:\/\/feather.dev\/proxy.php?proxy=forward_thumbnail&module=system&v=current&b=DEV&context=upload&name=2015-04%2FqsnpVUKobtOA7SvND0MF94wYJ2ub8pPmH3CrMcGN&original_file_name=durmitor.txt&width=--WIDTH--&height=--HEIGHT--&ver=95&scale=--SCALE--" } ], "labels": [], "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "project_id": 1, "is_hidden_from_clients": false, "body": "", "body_formatted": "", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164955, "updated_by_id": 1, "task_number": 1, "task_list_id": 0, "position": 1, "is_important": false, "due_on": null, "estimate": 0, "job_type_id": 0, "total_subtasks": 0, "completed_subtasks": 0, "open_subtasks": 0 }, "subscribers": [ 1 ], "comments": [ { "id": 1, "class": "Comment", "url_path": "\/comments\/1", "attachments": [], "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "parent_type": "Task", "parent_id": 1, "body": "Comment body", "body_formatted": "Comment body", "body_plain_text": "Comment body", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164954, "updated_by_id": 1 } ], "reminders": [], "subtasks": [], "task_list": null, "tracked_time": 0, "tracked_expenses": 0 }
Payload:
1 2 3 4 5
{ "attach_uploaded_files": [ "Mrz5fT26W15Nh6OMunZ8OicHG4aE1mfgLmt2gfQS" ] }
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
{ "single": { "id": 1, "class": "Comment", "url_path": "\/comments\/1", "attachments": [ { "id": 2, "name": "result-item.txt", "mime_type": "text\/plain", "size": 58, "disposition": "attachment", "thumbnail_url": "http:\/\/feather.dev\/proxy.php?proxy=forward_thumbnail&module=system&v=current&b=DEV&context=upload&name=2015-04%2FhA0fDBeChSOunrZu9Zd02rbbEzJmNAuczzG1D08l&original_file_name=result-item.txt&width=--WIDTH--&height=--HEIGHT--&ver=58&scale=--SCALE--" } ], "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "parent_type": "Task", "parent_id": 1, "body": "Comment body", "body_formatted": "Comment body", "body_plain_text": "Comment body", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164956, "updated_by_id": 1 } }
First one will hit the task because we have a word montenegro
in the task name:
Query Parameters:
1 2 3
{ "q": "montenegro" }
Response:
1
[]
Second one will hit the task because we have a file named durmitor.txt
attached to the task:
Query Parameters:
1 2 3
{ "q": "durmitor.txt" }
Response:
1
[]
Third one will hit the task because there is a word Kosanica
mentioned in the file:
Query Parameters:
1 2 3
{ "q": "kosanica" }
Response:
1
[]
Fourth search returns the task because it has a comment with an attachment that has the word mentioned in its content:
Query Parameters:
1 2 3
{ "q": "elastica" }
Response:
1
[]
Just to confirm that search is not always hitting our task:
Query Parameters:
1 2 3
{ "q": "abracadabra" }
Response:
1
[]
If we delete a comment (and all of its attachments), that should affect the seach. First, move comment to the trash:
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
{ "single": { "id": 1, "class": "Comment", "url_path": "\/comments\/1", "attachments": [ { "id": 2, "name": "result-item.txt", "mime_type": "text\/plain", "size": 58, "disposition": "attachment", "thumbnail_url": "http:\/\/feather.dev\/proxy.php?proxy=forward_thumbnail&module=system&v=current&b=DEV&context=upload&name=2015-04%2FhA0fDBeChSOunrZu9Zd02rbbEzJmNAuczzG1D08l&original_file_name=result-item.txt&width=--WIDTH--&height=--HEIGHT--&ver=58&scale=--SCALE--" } ], "is_trashed": true, "trashed_on": 1430164957, "trashed_by_id": 1, "parent_type": "Task", "parent_id": 1, "body": "Comment body", "body_formatted": "Comment body", "body_plain_text": "Comment body", "created_on": 1430164954, "created_by_id": 1, "updated_on": 1430164957, "updated_by_id": 1 } }
Now, we check if index is correct (by pulling the task using a search term that still hits it):
Query Parameters:
1 2 3
{ "q": "montenegro" }
Response:
1
[]
And finally, we'll have a miss if we try to search for content that was in that attachment:
Query Parameters:
1 2 3
{ "q": "elastica" }
Response:
1
[]
Another scenario that we should test is removing an attachment. Here we go:
As in the previous test, we first test the data with a query that we know will return the task:
Query Parameters:
1 2 3
{ "q": "montenegro" }
Response:
1
[]
Now we search for a term that was in the attachment that we just deleted:
Query Parameters:
1 2 3
{ "q": "kosanica" }
Response:
1
[]