Search by Concept
Search based on specific words.
You can search for concepts by name, even in a different language using the concept searches endpoint:
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiConceptResponse postConceptsSearchesResponse = stub.postConceptsSearches(
8
PostConceptsSearchesRequest.newBuilder()
9
.setConceptQuery(
10
ConceptQuery.newBuilder()
11
.setName("人")
12
.setLanguage("ja")
13
)
14
.build()
15
);
16
17
if (postConceptsSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
18
throw new RuntimeException("Post concepts searches failed, status: " + postConceptsSearchesResponse.getStatus());
19
}
20
21
System.out.println("Found concepts:");
22
for (Concept concept : postConceptsSearchesResponse.getConceptsList()) {
23
System.out.printf("\t%s %.2f%n", concept.getName(), concept.getValue());
24
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostConceptsSearches(
5
{
6
concept_query: {name: "人", language: "ja"}
7
},
8
metadata,
9
(err, response) => {
10
if (err) {
11
throw new Error(err);
12
}
13
14
if (response.status.code !== 10000) {
15
throw new Error("Post concepts searches failed, status: " + response.status.description);
16
}
17
18
console.log("Found concepts:");
19
for (const concept of response.concepts) {
20
console.log("\t" + concept.name + " " + concept.value);
21
}
22
}
23
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_concepts_searches_response = stub.PostConceptsSearches(
5
service_pb2.PostConceptsSearchesRequest(
6
concept_query=resources_pb2.ConceptQuery(
7
name="人",
8
language="ja"
9
)
10
),
11
metadata=metadata
12
)
13
14
if post_concepts_searches_response.status.code != status_code_pb2.SUCCESS:
15
print("There was an error with your request!")
16
print("\tCode: {}".format(post_concepts_searches_response.outputs[0].status.code))
17
print("\tDescription: {}".format(post_concepts_searches_response.outputs[0].status.description))
18
print("\tDetails: {}".format(post_concepts_searches_response.outputs[0].status.details))
19
raise Exception("Post concepts searches failed, status: " + post_concepts_searches_response.status.description)
20
21
print("Found concepts:")
22
for concept in post_concepts_searches_response.concepts:
23
print("\t%s %.2f" % (concept.name, concept.value))
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"concept_query": {
7
"name":"人",
8
"language": "ja"
9
}
10
}'\
11
https://api.clarifai.com/v2/concepts/searches
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"concept_query": {
7
"name":"人",
8
"language": "ja"
9
}
10
});
11
12
const requestOptions = {
13
method: 'POST',
14
headers: {
15
'Accept': 'application/json',
16
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
17
},
18
body: raw
19
};
20
21
fetch("https://api.clarifai.com/v2/concepts/searches", requestOptions)
22
.then(response => response.text())
23
.then(result => console.log(result))
24
.catch(error => console.log('error', error));
Copied!
Response JSON
1
{
2
"status": {
3
"code": 10000,
4
"description": "Ok"
5
},
6
"concepts": [
7
{
8
"id": "ai_l8TKp2h5",
9
"name": "人",
10
"created_at": "2016-03-17T11:43:01Z",
11
"updated_at": "2016-03-17T11:43:01Z",
12
"app_id": null,
13
"language": "zh"
14
},
15
{
16
"id": "ai_ZKJ48TFz",
17
"name": "人",
18
"created_at": "2016-03-17T11:43:01Z",
19
"updated_at": "2016-03-17T11:43:01Z",
20
"app_id": null,
21
"language": "zh"
22
},
23
{
24
"id": "ai_GlPlRlTZ",
25
"name": "人为破坏",
26
"created_at": "2016-03-17T11:43:01Z",
27
"updated_at": "2016-03-17T11:43:01Z",
28
"app_id": null,
29
"language": "zh"
30
},
31
{
32
"id": "ai_8ZsdCrVZ",
33
"name": "人体模型",
34
"created_at": "2016-03-17T11:43:01Z",
35
"updated_at": "2016-03-17T11:43:01Z",
36
"app_id": null,
37
"language": "zh"
38
},
39
{
40
"id": "ai_K1KL0zgk",
41
"name": "人力的",
42
"created_at": "2016-03-17T11:43:01Z",
43
"updated_at": "2016-03-17T11:43:01Z",
44
"app_id": null,
45
"language": "zh"
46
},
47
{
48
"id": "ai_Tm9d2BZ2",
49
"name": "人口",
50
"created_at": "2016-03-17T11:43:01Z",
51
"updated_at": "2016-03-17T11:43:01Z",
52
"app_id": null,
53
"language": "zh"
54
},
55
{
56
"id": "ai_NLF8h1fJ",
57
"name": "人口",
58
"created_at": "2016-03-17T11:43:01Z",
59
"updated_at": "2016-03-17T11:43:01Z",
60
"app_id": null,
61
"language": "zh"
62
},
63
{
64
"id": "ai_8bHdFtsg",
65
"name": "人口",
66
"created_at": "2016-03-17T11:43:01Z",
67
"updated_at": "2016-03-17T11:43:01Z",
68
"app_id": null,
69
"language": "zh"
70
},
71
{
72
"id": "ai_vLnr3Mcj",
73
"name": "人孔",
74
"created_at": "2016-03-17T11:43:01Z",
75
"updated_at": "2016-03-17T11:43:01Z",
76
"app_id": null,
77
"language": "zh"
78
},
79
{
80
"id": "ai_HRt4nfvL",
81
"name": "人工智能",
82
"created_at": "2016-03-17T11:43:01Z",
83
"updated_at": "2016-03-17T11:43:01Z",
84
"app_id": null,
85
"language": "zh"
86
},
87
{
88
"id": "ai_Qc3mqxTJ",
89
"name": "人才",
90
"created_at": "2016-03-17T11:43:01Z",
91
"updated_at": "2016-03-17T11:43:01Z",
92
"app_id": null,
93
"language": "zh"
94
},
95
{
96
"id": "ai_VFKQ0qD6",
97
"name": "人物",
98
"created_at": "2016-03-17T11:43:01Z",
99
"updated_at": "2016-03-17T11:43:01Z",
100
"app_id": null,
101
"language": "zh"
102
},
103
{
104
"id": "ai_Wz8JXXMB",
105
"name": "人类免疫缺陷病毒",
106
"created_at": "2016-03-17T11:43:01Z",
107
"updated_at": "2016-03-17T11:43:01Z",
108
"app_id": null,
109
"language": "zh"
110
},
111
{
112
"id": "ai_bzp3Lg81",
113
"name": "人类的",
114
"created_at": "2016-03-17T11:43:01Z",
115
"updated_at": "2016-03-17T11:43:01Z",
116
"app_id": null,
117
"language": "zh"
118
},
119
{
120
"id": "ai_dJ15S9s6",
121
"name": "人群",
122
"created_at": "2016-03-17T11:43:01Z",
123
"updated_at": "2016-03-17T11:43:01Z",
124
"app_id": null,
125
"language": "zh"
126
},
127
{
128
"id": "ai_MNCVrmml",
129
"name": "人行天桥",
130
"created_at": "2016-03-17T11:43:01Z",
131
"updated_at": "2016-03-17T11:43:01Z",
132
"app_id": null,
133
"language": "zh"
134
},
135
{
136
"id": "ai_CChWH41S",
137
"name": "人行横道",
138
"created_at": "2016-03-17T11:43:01Z",
139
"updated_at": "2016-03-17T11:43:01Z",
140
"app_id": null,
141
"language": "zh"
142
},
143
{
144
"id": "ai_4lbXrFgT",
145
"name": "人造",
146
"created_at": "2016-03-17T11:43:01Z",
147
"updated_at": "2016-03-17T11:43:01Z",
148
"app_id": null,
149
"language": "zh"
150
},
151
{
152
"id": "ai_277LRf4d",
153
"name": "人造卫星",
154
"created_at": "2016-03-17T11:43:01Z",
155
"updated_at": "2016-03-17T11:43:01Z",
156
"app_id": null,
157
"language": "zh"
158
},
159
{
160
"id": "ai_H3RDmvSn",
161
"name": "人造奶油",
162
"created_at": "2016-03-17T11:43:01Z",
163
"updated_at": "2016-03-17T11:43:01Z",
164
"app_id": null,
165
"language": "zh"
166
}
167
]
168
}
Copied!
Last modified 1mo ago
Copy link
Edit on GitHub