com.algolia.search.saas.Query.setTagFilters()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中com.algolia.search.saas.Query.setTagFilters方法的一些代码示例,展示了Query.setTagFilters的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setTagFilters方法的具体详情如下:
包路径:com.algolia.search.saas.Query
类名称:Query
方法名:setTagFilters

Query.setTagFilters介绍

[英]Filter the query by a set of tags. You can AND tags by separating them by commas. To OR tags, you must add parentheses. For example tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3). At indexing, tags should be added in the _tags attribute of objects (for example {"_tags":["tag1","tag2"]} )
[中]

代码示例

代码示例来源:origin: algolia/algoliasearch-client-java

/**
 * Generate a secured and public API Key from a list of tagFilters and an
 * optional user token identifying the current user
 *
 * @param privateApiKey your private API Key
 * @param tagFilters    the list of tags applied to the query (used as security)
 * @deprecated Use `generateSecuredApiKey(String privateApiKey, Query query)` version
 */
@Deprecated
public String generateSecuredApiKey(String privateApiKey, String tagFilters) throws NoSuchAlgorithmException, InvalidKeyException {
 if (!tagFilters.contains("="))
  return generateSecuredApiKey(privateApiKey, new Query().setTagFilters(tagFilters), null);
 else {
  return Base64.encodeBase64String(String.format("%s%s", hmac(privateApiKey, tagFilters), tagFilters).getBytes(Charset.forName("UTF8")));
 }
}

代码示例来源:origin: algolia/algoliasearch-client-java

/**
 * Generate a secured and public API Key from a list of tagFilters and an
 * optional user token identifying the current user
 *
 * @param privateApiKey your private API Key
 * @param tagFilters    the list of tags applied to the query (used as security)
 * @param userToken     an optional token identifying the current user
 * @deprecated Use `generateSecuredApiKey(String privateApiKey, Query query, String userToken)` version
 */
@Deprecated
public String generateSecuredApiKey(String privateApiKey, String tagFilters, String userToken) throws NoSuchAlgorithmException, InvalidKeyException, AlgoliaException {
 if (!tagFilters.contains("="))
  return generateSecuredApiKey(privateApiKey, new Query().setTagFilters(tagFilters), userToken);
 else {
  if (userToken != null && userToken.length() > 0) {
   try {
    tagFilters = String.format("%s%s%s", tagFilters, "&userToken=", URLEncoder.encode(userToken, "UTF-8"));
   } catch (UnsupportedEncodingException e) {
    throw new AlgoliaException(e.getMessage());
   }
  }
  return Base64.encodeBase64String(String.format("%s%s", hmac(privateApiKey, tagFilters), tagFilters).getBytes(Charset.forName("UTF8")));
 }
}

代码示例来源:origin: algolia/algoliasearch-client-android

@Test
public void tagFilters() throws JSONException {
  final JSONArray VALUE = new JSONArray("[\"tag1\", [\"tag2\", \"tag3\"]]");
  Query query = new Query();
  assertNull(query.getTagFilters());
  query.setTagFilters(VALUE);
  assertEquals(VALUE, query.getTagFilters());
  assertEquals("[\"tag1\",[\"tag2\",\"tag3\"]]", query.get("tagFilters"));
  assertEquals(query.getTagFilters(), Query.parse(query.build()).getTagFilters());
}

相关文章