Search Discussions

For the purpose of this test, we have created two projects:

Response: HTTP 200, application/json (Hide)
GET /projects

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
75
76
[
    {
        "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": 1430164079,
        "created_by_id": 1,
        "updated_on": 1430164079,
        "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-wzjI5pF@mail.manageprojects.com",
        "is_tracking_enabled": true,
        "is_client_reporting_enabled": false,
        "budget": null,
        "count_tasks": 0,
        "count_discussions": 0,
        "count_files": 0,
        "count_notes": 0
    },
    {
        "id": 2,
        "class": "Project",
        "url_path": "\/projects\/2",
        "name": "Another 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": 1430164079,
        "created_by_id": 1,
        "updated_on": 1430164079,
        "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-OMgqheD@mail.manageprojects.com",
        "is_tracking_enabled": true,
        "is_client_reporting_enabled": false,
        "budget": null,
        "count_tasks": 0,
        "count_discussions": 0,
        "count_files": 0,
        "count_notes": 0
    }
]

To get started, we will create a couple of discussions and comments:

Response: HTTP 200, application/json (Hide)
POST /projects/2/discussions

Payload:

1
2
3
4
{
    "name": "Belgrade trip",
    "body": "Plan the trip. Common term: Serbia"
}

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
{
    "single": {
        "id": 2,
        "class": "Discussion",
        "url_path": "\/projects\/2\/discussions\/2",
        "name": "Belgrade trip",
        "comments_count": 0,
        "attachments": [],
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "project_id": 2,
        "is_hidden_from_clients": false,
        "body": "Plan the trip. Common term: Serbia",
        "body_formatted": "Plan the trip. Common term: Serbia",
        "created_on": 1430164080,
        "created_by_id": 1,
        "updated_on": 1430164080,
        "updated_by_id": 1
    },
    "subscribers": [
        1
    ],
    "comments": []
}
Response: HTTP 200, application/json (Hide)
POST /comments/discussion/1

Payload:

1
2
3
{
    "body": "Novi Sad is the second largest city in Serbia"
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
    "single": {
        "id": 1,
        "class": "Comment",
        "url_path": "\/comments\/1",
        "attachments": [],
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "parent_type": "Discussion",
        "parent_id": 1,
        "body": "Novi Sad is the second largest city in Serbia",
        "body_formatted": "Novi Sad is the second largest city in Serbia",
        "body_plain_text": "Novi Sad is the second largest city in Serbia",
        "created_on": 1430164080,
        "created_by_id": 1,
        "updated_on": 1430164080,
        "updated_by_id": 1
    }
}
Response: HTTP 200, application/json (Hide)
POST /comments/discussion/2

Payload:

1
2
3
{
    "body": "Belgrade is capital of Serbia"
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
    "single": {
        "id": 2,
        "class": "Comment",
        "url_path": "\/comments\/2",
        "attachments": [],
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "parent_type": "Discussion",
        "parent_id": 2,
        "body": "Belgrade is capital of Serbia",
        "body_formatted": "Belgrade is capital of Serbia",
        "body_plain_text": "Belgrade is capital of Serbia",
        "created_on": 1430164081,
        "created_by_id": 1,
        "updated_on": 1430164081,
        "updated_by_id": 1
    }
}

Lets search for a common term:

Response: HTTP 200, application/json (Hide)
GET /search?q=serbia

Response:

1
[]

Now lets limit the search on just one project:

Response: HTTP 200, application/json (Hide)
GET /search?q=serbia&project_id=1

Response:

1
[]

Lets search for a less common term:

Response: HTTP 200, application/json (Hide)
GET /search?q=capital

Response:

1
[]