本文整理了Java中com.algolia.search.saas.Query.getNumericFilters
方法的一些代码示例,展示了Query.getNumericFilters
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getNumericFilters
方法的具体详情如下:
包路径:com.algolia.search.saas.Query
类名称:Query
方法名:getNumericFilters
[英]Get the value of deprecated facetFilters parameter.
[中]获取不推荐的facetFilters参数的值。
代码示例来源:origin: algolia/algoliasearch-client-android
@Test
public void numericFilters() throws JSONException {
final JSONArray VALUE = new JSONArray("[\"code=1\", [\"price:0 to 10\", \"price:1000 to 2000\"]]");
Query query = new Query();
assertNull(query.getNumericFilters());
query.setNumericFilters(VALUE);
assertEquals(VALUE, query.getNumericFilters());
assertEquals("[\"code=1\",[\"price:0 to 10\",\"price:1000 to 2000\"]]", query.get("numericFilters"));
assertEquals(query.getNumericFilters(), Query.parse(query.build()).getNumericFilters());
}
代码示例来源:origin: algolia/instantsearch-android
@Test
public void numericRefinements() {
Searcher searcher = initSearcher();
final NumericRefinement r = new NumericRefinement("attribute", NumericRefinement.OPERATOR_EQ, 42);
final NumericRefinement r2 = new NumericRefinement("attribute", NumericRefinement.OPERATOR_NE, 42);
final String formattedValue = String.format(Locale.US, "%f", 42f);
searcher.addNumericRefinement(r);
Assert.assertEquals("There should be a numeric refinement for attribute", r, searcher.getNumericRefinement(r.attribute, r.operator));
Assert.assertEquals("Query numericFilters should represent the refinement", "[\"attribute=" + formattedValue + "\"]", searcher.getQuery().getNumericFilters().toString());
searcher.removeNumericRefinement(r);
Assert.assertEquals("This numeric refinement should have been removed.", null, searcher.getNumericRefinement(r.attribute, r.operator));
Assert.assertEquals("Query numericFilters should be empty after removal", "[]", searcher.getQuery().getNumericFilters().toString());
searcher.addNumericRefinement(r);
searcher.addNumericRefinement(r2);
Assert.assertEquals("Query numericFilters should represent both refinements", "[\"attribute=" + formattedValue + "\",\"attribute!=" + formattedValue + "\"]", searcher.getQuery().getNumericFilters().toString());
searcher.removeNumericRefinement(r.attribute);
Assert.assertEquals("Both numeric refinements for this attribute should have been removed", null, searcher.getNumericRefinement(r.attribute, r.operator));
Assert.assertEquals("Query numericFilters should be empty after removal", "[]", searcher.getQuery().getNumericFilters().toString());
searcher.addNumericRefinement(r);
searcher.addNumericRefinement(r2);
searcher.removeNumericRefinement(r.attribute, r.operator);
Assert.assertEquals("The numeric refinement for this attribute/operator pair should have been removed", null, searcher.getNumericRefinement(r.attribute, r.operator));
Assert.assertEquals("The numeric refinement for this attribute but other operator should have been kept", r2, searcher.getNumericRefinement(r2.attribute, r2.operator));
}
内容来源于网络,如有侵权,请联系作者删除!