ユーザー検索のクエリ構文

ユーザーを検索するとき、Luceneクエリ構文を使用してクエリを作成し、検索を絞り込むことができます。

クエリ文字列は、一連のタームと演算子に解析されます。

  • タームは、janesmithなどの1つの単語の場合があります。

  • タームは、二重引用符で囲まれたフレーズ("green apple")の場合があり、同じ順序のフレーズのすべての担当が一致します。

  • フィールド名のないタームは、ユーザーメタデータフィールドのテキストと一致しません。

  • 複数のタームは、括弧を使ってグループにまとめ、サブクエリにすることができます。

  • 正規化されたユーザーフィールド(emailnamegiven_namefamily_name、およびnickname)の検索値は、大文字と小文字を区別しません。その他すべてのフィールド(すべてのapp_metadata/user_metadatafi-rudo/user_metadataフィールドを含む)は、大文字と小文字を区別します。

  • 演算子(ANDORNOT)は、正規化されたユーザーフィールドおよびルートメタデータフィールドのすべてで機能します。

  • 演算子は、常に大文字である必要があります。

検索可能なフィールド

すべての正規化ユーザープロファイルフィールドおよび以下のフィールドを使用して、ユーザーを検索できます。

検索フィールド データタイプ 説明
phone_number テキスト ユーザーの電話番号です。SMS接続のあるユーザーに対してのみ有効です。
phone_verified ブール値 true/falseの値は、ユーザーの電話番号が検証されたかを示します。SMS接続のあるユーザーに対してのみ有効です。
logins_count 整数 ユーザーがログインした回数です。ブロックされているユーザーがログインした場合、ブロックされたセッションがlogins_countに算入され、last_loginの値が更新されます。
created_at 日時 ユーザープロファイルが最初に作成された日時を示すタイムスタンプです。
updated_at 日時 ユーザープロファイルが最後に更新または変更された日を示すタイムスタンプです。
last_login 日時 ユーザーが最後にログインした日時を示すタイムスタンプです。このプロパティがルール内からuserオブジェクトを伴って実行される場合、値はルールを起動したログインと関連付けられます(ルールは実際のログインの後に実行されるからです)。
last_ip テキスト(有効なIPアドレス) ユーザーの最後のログインと関連付けられたIPアドレスです。
blocked ブール値 trueまたはfalseの値は、ユーザーがブロックされているかを示します。注意:trueは、Admin DashboardまたはManagement APIを使用してブロックされたユーザーのみ復旧させます。総当たり攻撃の異常検知でブロックされたユーザーは復旧しません。
email.domain テキスト ユーザーのメールアドレスのドメイン部分です。
organization_id テキスト(有効な組織ID) ユーザーがメンバーである組織です。

メタデータフィールドは、以下と使用できます。

  • ブール値

  • 数値:integerまたはdouble

  • 文字

  • オブジェクト:別のオブジェクトにネストされているスカラー値を検索するには、フィールドへのパスを使用します。たとえば、app_metadata.subscription.plan:"gold"

  • 配列:配列にネストされているオブジェクト内のフィールドを検索するには、フィールドへのパスを使用し、配列レベルを無視します。たとえば、user_metadata.addresses.city:"Paris"

空の配列、空のオブジェクト、またはnull値を含むメタフィールドは、インデックスされていないため、検索できません。

範囲検索とワイルドカード検索は、user_metadataフィールドで使用できません。

完全一致

完全一致で検索するには、二重引用符を使用します:name:"jane smith"

たとえば、jane smithという名前のユーザーを検索するには、q=name:"jane smith"を使用します。


curl --request GET \
  --url 'https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3' \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

Was this helpful?

/
var client = new RestClient("https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
IRestResponse response = client.Execute(request);

Was this helpful?

/
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Was this helpful?

/
HttpResponse<String> response = Unirest.get("https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3")
  .header("authorization", "Bearer {yourMgmtApiAccessToken}")
  .asString();

Was this helpful?

/
var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://{yourDomain}/api/v2/users',
  params: {q: 'name:"jane smith"', search_engine: 'v3'},
  headers: {authorization: 'Bearer {yourMgmtApiAccessToken}'}
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

Was this helpful?

/
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"authorization": @"Bearer {yourMgmtApiAccessToken}" };

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];

Was this helpful?

/
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "authorization: Bearer {yourMgmtApiAccessToken}"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Was this helpful?

/
import http.client

conn = http.client.HTTPSConnection("")

headers = { 'authorization': "Bearer {yourMgmtApiAccessToken}" }

conn.request("GET", "/{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Was this helpful?

/
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'

response = http.request(request)
puts response.read_body

Was this helpful?

/
import Foundation

let headers = ["authorization": "Bearer {yourMgmtApiAccessToken}"]

let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/users?q=name%3A%22jane%20smith%22&search_engine=v3")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

Was this helpful?

/

ワイルドカード

ワイルドカード検索は、アスタリスク文字(*)を使用して0以上の文字を置換するタームに実行できます。ワイルドカード検索は、user_metadataフィールドで使用できません。

  • name:john*は、名前の始めにjohnがあるユーザーすべてを返します。

  • name:j*は、名前の始めにjがあるユーザーすべてを返します。

  • q=name:john* は、 johnで始まる名前のユーザーすべてを返します。

  • サフィックスの照合の場合、リテラルは3文字以上である必要があります。たとえば、name:*usaは使用できますが、name:*saは使用できません。


curl --request GET \
  --url 'https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3' \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

Was this helpful?

/
var client = new RestClient("https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
IRestResponse response = client.Execute(request);

Was this helpful?

/
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Was this helpful?

/
HttpResponse<String> response = Unirest.get("https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3")
  .header("authorization", "Bearer {yourMgmtApiAccessToken}")
  .asString();

Was this helpful?

/
var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://{yourDomain}/api/v2/users',
  params: {q: 'name:john*', search_engine: 'v3'},
  headers: {authorization: 'Bearer {yourMgmtApiAccessToken}'}
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

Was this helpful?

/
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"authorization": @"Bearer {yourMgmtApiAccessToken}" };

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];

Was this helpful?

/
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "authorization: Bearer {yourMgmtApiAccessToken}"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Was this helpful?

/
import http.client

conn = http.client.HTTPSConnection("")

headers = { 'authorization': "Bearer {yourMgmtApiAccessToken}" }

conn.request("GET", "/{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Was this helpful?

/
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'

response = http.request(request)
puts response.read_body

Was this helpful?

/
import Foundation

let headers = ["authorization": "Bearer {yourMgmtApiAccessToken}"]

let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/users?q=name%3Ajohn*&search_engine=v3")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

Was this helpful?

/

範囲

ユーザー検索クエリで範囲を使用することができます。範囲検索は、ユーザーメタデータフィールドで使用できません。

  • 包括範囲の場合は、角括弧を使用します:[min TO max]

  • 排他的な範囲には、中括弧を使用します:{min TO max}

  • 中括弧と角括弧は同じ範囲の表現内で組み合わせることができます:logins_count:[100 TO 200}

  • ワイルドカードと組み合わせて範囲を使用します。たとえば、100回以上ログインしているユーザーを見つけるには、 q=logins_count:{100 TO *]を使用します。


curl --request GET \
  --url 'https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3' \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

Was this helpful?

/
var client = new RestClient("https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
IRestResponse response = client.Execute(request);

Was this helpful?

/
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Was this helpful?

/
HttpResponse<String> response = Unirest.get("https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3")
  .header("authorization", "Bearer {yourMgmtApiAccessToken}")
  .asString();

Was this helpful?

/
var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://{yourDomain}/api/v2/users',
  params: {q: 'logins_count:{100 TO *]', search_engine: 'v3'},
  headers: {authorization: 'Bearer {yourMgmtApiAccessToken}'}
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

Was this helpful?

/
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"authorization": @"Bearer {yourMgmtApiAccessToken}" };

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];

Was this helpful?

/
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "authorization: Bearer {yourMgmtApiAccessToken}"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Was this helpful?

/
import http.client

conn = http.client.HTTPSConnection("")

headers = { 'authorization': "Bearer {yourMgmtApiAccessToken}" }

conn.request("GET", "/{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Was this helpful?

/
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'

response = http.request(request)
puts response.read_body

Was this helpful?

/
import Foundation

let headers = ["authorization": "Bearer {yourMgmtApiAccessToken}"]

let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/users?q=logins_count%3A%7B100%20TO%20*%5D&search_engine=v3")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()

Was this helpful?

/

検索可能なプロファイル属性の例

Auth0管理APIのユーザーを検索する場合、user_metadataまたはapp_metadataで、ユーザーをフィルタリングできます。これを行うには、q パラメーターのLucene検索構文を使用できます。

Auth0管理APIリストまたは検索ユーザーエンドポイントは、結果が1000に制限されているため(レコード100件の10ページ)、フィルタリングは、最も関連性の高い結果が返るようにするのに役立ちます。

以下は、ユーザープロファイルuser_metadataの例です。

{
  "favorite_color": "blue",
  "approved": false,
  "preferredLanguage": "en",
  "preferences": {
    "fontSize": 13
  },
  "addresses":{
    "city":["Paris","Seattle"]
  }
}

Was this helpful?

/

メタデーター属性のフィルタリング

user_metadata値を返すには、属性のフィルタリングを付けてqクエリを更新します。

User_metadata 値については、プロファイルに直接クエリを実行できます。

q:_exists_:user_metadata.fav_color

このクエリは、user_metadatafav_color属性を持つユーザープロファイルすべてを返します。

メタデータのネストされたオブジェクト属性および値をフィルタリング

またuser_metadataのネストされたオブジェクトを検索できます:

q:_exists_:user_metadata.preferences.fontSize

これは、user_metadatapreferences.fontSizeに構成されたユーザープロファイルすべてにクエリを実行します。

別のオブジェクトからネストされたオブジェクトの値を検索するには、以下のクエリを参照してください。

q: user_metadata.preferences.fontSize:13

このクエリは、13の値のfontSize属性と一致するユーザープロファイルすべてを返します。

メタデータのネストされた配列値をフィルタリング

ネストされた配列のフィールドを検索するために、以下のクエリを使用できます。

q: user_metadata.addresses.city:"Seattle"

これは、user_metadataaddress.city 属性からSeattleの値を返したユーザープロファイルのすべてを返します。

もっと詳しく