如何根据algolia即时搜索中的类别过滤匹配

时间:2017-10-09 03:54:42

标签: android geolocation algolia

我想根据他们的类别过滤点击次数,例如商店或咖啡。

这是我的疑问:

...
import React from 'react';
import QueryString from 'query-string';
import 'whatwg-fetch';
import { Link } from 'react-router-dom';

...
export default class IssueList extends React.Component{
   constructor(props){
       super(props);
       this.state = { issues: [] };
       this.createIssue = this.createIssue.bind(this);
       this.setFilter = this.setFilter.bind(this);
   }

   setFilter(query){
       this.props.history.push({ 
           pathname: this.props.location.pathname, 
           search: '?' + QueryString.stringify(query) 
       });
   }
}

如何过滤我得到的结果?

1 个答案:

答案 0 :(得分:4)

查看Algolia's Filtering Guide,了解过滤的工作原理。

使用Android客户端,您可以使用setFilters方法:

Query query = new Query("foo");
query.setFilters("category:coffee"); 

您可以在client's documentation

中找到更多信息
/**
 * Filter the query with numeric, facet or/and tag filters.
 * <p>
 * The syntax is a SQL like syntax, you can use the OR and AND keywords. The syntax for the underlying numeric, facet and tag filters is the same than in the other filters:
 * {@code available=1 AND (category:Book OR NOT category:Ebook) AND _tags:public date: 1441745506 TO 1441755506 AND inStock > 0 AND author:"John Doe"}
 *
 * @param filters a string following the given syntax.
 * @return the {@link Query} for chaining.
 */
public @NonNull Query setFilters(String filters)