Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code-examples/curl/search/advanced-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
],
"page": 1,
"request_params": {
"collection_name": "identities-f59802a6-eb63-44cc-a3ac-d90db3d3abc2",
"collection_name": "identities",
"first_q": "*",
"per_page": 20,
"q": "*"
Expand Down
3 changes: 1 addition & 2 deletions code-examples/curl/search/advanced.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export ORY_API_KEY="ory_pat_XXXXXXXXXXXXXXXX"
export COLLECTION="identities-d7c52eed-e45c-4483-af3b-4aaa5782bff7" # replace with your project ID
export ORY_SLUG="upbeat-lalande-zu8omm6wwp" # replace with your Ory slug

# list identities which do not have two-factor authentication enabled,
# resolved by the organization to which they belong,
# ordered by creation date (newest first),
# and limited to 20 per page
curl -H "Authorization: Bearer $ORY_API_KEY" \
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/$COLLECTION/documents/search" \
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/identities/documents/search" \
--url-query 'q=*' \
--url-query 'filter_by=available_aal:!=aal2' \
--url-query 'facet_by=organization_id' \
Expand Down
5 changes: 2 additions & 3 deletions code-examples/curl/search/basic.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export ORY_API_KEY="ory_pat_XXXXXXXXXXXXXXXX"
export COLLECTION="identities-d7c52eed-e45c-4483-af3b-4aaa5782bff7" # replace with your project ID
export ORY_SLUG="upbeat-lalande-zu8omm6wwp" # replace with your Ory slug

# List identities via Search API
curl -H "Authorization: Bearer $ORY_API_KEY" \
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/$COLLECTION/documents/search?q=*"
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/identities/documents/search?q=*"

# Search for "foo" in the email trait
curl -H "Authorization: Bearer $ORY_API_KEY" \
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/$COLLECTION/documents/search?q=foo&query_by=traits.email"
"https://$ORY_SLUG.projects.oryapis.com/admin/preview/search/v0beta1/collections/identities/documents/search?q=foo&query_by=traits.email"
7 changes: 3 additions & 4 deletions code-examples/sdk/go/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import (
var (
ORY_PROJECT_URL = os.Getenv("ORY_PROJECT_URL")
ORY_API_KEY = os.Getenv("ORY_API_KEY")
Collection = "identities-" + os.Getenv("ORY_PROJECT_ID")
)

func main() {
ctx := context.WithValue(context.Background(), ory.ContextAccessToken, os.Getenv("ORY_API_KEY"))
ctx := context.WithValue(context.Background(), ory.ContextAccessToken, ORY_API_KEY)

// Initialize Ory client
cfg := ory.NewConfiguration()
Expand All @@ -34,7 +33,7 @@ func main() {

// highlight-start
// List identities via Search API
list, err := searchClient.Collection(Collection).Documents().Search(ctx, &typesenseapi.SearchCollectionParams{
list, err := searchClient.Collection("identities").Documents().Search(ctx, &typesenseapi.SearchCollectionParams{
Q: ptr("*"),
})
// highlight-end
Expand All @@ -49,7 +48,7 @@ func main() {

// highlight-start
// Search identities via Search API
search, err := searchClient.Collection(Collection).Documents().Search(ctx, &typesenseapi.SearchCollectionParams{
search, err := searchClient.Collection("identities").Documents().Search(ctx, &typesenseapi.SearchCollectionParams{
Q: ptr("foo"),
QueryBy: ptr("traits"),
})
Expand Down
3 changes: 1 addition & 2 deletions code-examples/sdk/java/search/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public static void main(String[] args) {
Client searchClient = initializeSearchClient();
// highlight-start
// Search identities via Search API
String collection = "identities-" + System.getenv("ORY_PROJECT_ID"); // Set the collection name
SearchResult searchResult = searchClient.collections(collection).documents()
SearchResult searchResult = searchClient.collections("identities").documents()
.search(new SearchParameters().q("test@example.com").queryBy("traits.email"));
// highlight-end

Expand Down
15 changes: 11 additions & 4 deletions docs/kratos/manage-identities/search/identity-search-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import Help from '@site/docs/_common/need-help.mdx'

## Getting started

We recommend using the [Typesense SDKs](https://typesense.org/docs/29.0/api/api-clients.html) for your preferred language to
interact with the advanced identity search API. Pass your [Ory Network API key](/concepts/personal-access-token) where you would
normally pass the Typesense API key, use the following base URL:
Ory exposes an advanced Identity Search API that is compatible with the Typesense search protocol. You can use existing Typesense
SDKs to interact with it. Pass your [Ory Network API key](/concepts/personal-access-token) where you would normally pass the
Typesense API key, and use the following base URL:

```shell
https://{your-ory-slug}.projects.oryapis.com/admin/preview/search/v0beta1
```

and set the collection name to `identities-{your-project-id}`.
and query the collection named `identities`.

See the following examples for how to configure and use the Typesense SDKs to search for identities.

Expand Down Expand Up @@ -105,6 +105,13 @@ possible.

:::

## Search result set limit

The identity search API does not support pagination (unlike the List Identities API) and will return a maximum of 1,000 results
per request. If you are frequently hitting this limit, consider refining your search queries to reduce the number of results
returned. To paginate through _all_ your identities, use the
[List Identities API](/reference/api#tag/identity/operation/listIdentities).

## Consistency and availability

The search index powering advanced identity search is eventually consistent with the main identity store. This means that there
Expand Down
Loading