본문 바로가기
개발/ALGOLIA

알고리아 Managing Results(3-25)

by dev_caleb 2022. 3. 5.
728x90

Filtering

 

https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/

 

Filtering | Algolia

How does filtering work with Algolia? Learn how Algolia enables filtered searches.

www.algolia.com

Filtering allows your users to drill-down and create a smaller, more manageable set of data based on meaningful categories. Categories can be brand, color, or genre of film. They can be dress or shoe sizes, or price ranges like expensive or cheap. They can be date ranges, booleans, user-defined tags, geolocation, and many other kinds of information that help classify your data. By classifying your data with filtering, you give your users direct control over the set of records they query.

Filtering is primarily used in the context of front-end search. We call this faceting, where filters are displayed on the search UI as clickable items, allowing users to select one or more filters. This enables a more refined, drilled-down search experience.

필터링을 사용하면 의미 있는 범주를 기반으로 더 작고 관리하기 쉬운 데이터 집합을 드릴다운하고 만들 수 있습니다. 카테고리는 영화의 브랜드, 색상 또는 장르가 될 수 있습니다. 그것들은 드레스나 신발 사이즈, 또는 비싸거나 싼 가격대일 수 있다. 날짜 범위, boolean, 사용자 정의 태그, 지리 위치 및 데이터를 분류하는 데 도움이 되는 여러 종류의 정보일 수 있습니다. 필터링으로 데이터를 분류하면 쿼리하는 레코드 집합을 사용자가 직접 제어할 수 있습니다.
필터링은 주로 프런트 엔드 검색의 맥락에서 사용됩니다. 이 기능을 패싱이라고 하는데, 검색 UI에 필터가 클릭 가능한 항목으로 표시되므로 사용자가 하나 이상의 필터를 선택할 수 있습니다. 이를 통해 보다 정교하고 심층적인 검색 환경을 구현할 수 있습니다.

 

 

How to Filter Your Data#

1. Define attributes that need to be filterable (at indexing time)

1. (인덱싱 시) 필터링할 수 있어야 하는 속성 정의

 

Initially, filter attributes must be defined as facets, using the attributesForFaceting parameter. This is done at indexing time, using the dashboard or an API client.

If you plan on using an attribute for filtering only, and not for computing counts for each facet value, you should use the filterOnly modifier. For example, if you plan to filter on an attribute, for example color, but never need to calculate or display the number of items with color:green, color:blue, etc., then you should use filterOnly. It reduces the index size and improve the speed of the search.

Note that if you use numericFilters to filter on numeric or boolean attributes, you don’t have to set these attributes as attributesForFaceting.

 

처음에 필터 특성은 AttributesForFaceting 매개 변수를 사용하여 패싯으로 정의되어야 합니다. 이 작업은 대시보드 또는 API 클라이언트를 사용하여 인덱싱할 때 수행됩니다.
각 패싯 값에 대한 카운트를 계산하지 않고 필터링에만 속성을 사용하려면 filterOnly 한정자를 사용해야 합니다. 예를 들어 색상과 같은 속성을 필터링할 계획이지만 색상:녹색, 색상:청색 등으로 항목 수를 계산하거나 표시할 필요가 없는 경우 filterOnly를 사용해야 합니다. 인덱스 크기를 줄이고 검색 속도를 향상시킵니다.
숫자 필터를 사용하여 숫자 또는 부울 특성을 필터링하는 경우 이러한 속성을 특성ForFaceting으로 설정할 필요가 없습니다.

 

 

2. Filter by Attributes (at query time)

The actual filtering of records is performed at query time, not at indexing time. For this, you need to use the filters parameter in your search code.

In all cases, filtering is based on attributes. Every record has one or more attributes that are designated as filters. A filter attribute can be a list of single words, or more complex phrases, or numerics, booleans, dates, or even arrays and nested arrays of related data. In the end, every filter or combination of filters can be used to group two or more records together. Ultimately, grouping by filters helps reduce noise, creating more targeted (relevant) subsets of data and increasing the chance that only the best results appear at the top.

레코드의 실제 필터링은 인덱싱 시간이 아닌 쿼리 시간에 수행됩니다. 이를 위해 검색 코드에서 필터 매개 변수를 사용해야 합니다.
모든 경우에 필터링은 attributes을 기반으로 합니다. 모든 레코드에는 필터로 지정된 하나 이상의 attributes이 있습니다. 필터 특성은 단일 단어 또는 더 복잡한 구, 숫자, 부울런, 날짜 또는 관련 데이터의 배열과 중첩된 배열의 목록이 될 수 있습니다. 결국 모든 필터 또는 필터 조합을 사용하여 둘 이상의 레코드를 그룹화할 수 있습니다. 궁극적으로 필터별로 그룹화하면 노이즈를 줄이는 데 도움이 되며, 더 많은 대상(관련된) 데이터 하위 집합을 만들고 가장 좋은 결과만 맨 위에 나타날 가능성을 높일 수 있습니다.

 

Filtering on objectID

By default, the engine sets a record’s objectID attribute as a filter-only facet. This means you can use the filters parameter to filter on objectID. This is useful when you want to include or exclude specific records in the current search. For example, to exclude the record with objectID“1234”, you can use the filter NOT objectID:1234 in the filters parameter of your search.

기본적으로 엔진은 레코드의 개체를 설정합니다.필터 전용 패싯으로 ID 특성을 지정합니다. 즉, 필터 매개 변수를 사용하여 객체를 필터링할 수 있습니다.ID. 현재 검색에 특정 레코드를 포함하거나 제외할 때 유용합니다. 예를 들어 객체가 있는 레코드를 제외하려면ID"1234"는 검색의 필터 매개 변수에 NOT objectID:1234 필터를 사용할 수 있습니다.

 

Combining Filters with Boolean Operators

Algolia’s filters parameter allows you to leverage boolean operators (AND, OR, NOT) and parentheses to combine individual filters, similar to SQL expression syntax.

Algolia의 필터 매개 변수를 사용하면 SQL 식 구문과 유사한 개별 필터를 결합하기 위해 부울 연산자(AND, OR, NOT)와 괄호를 사용할 수 있습니다.

Alternative Filtering Methods

facetFilters

It’s possible to filter hits using the facetFilters parameter. The functionality is mostly the same - they both filter records based on certain attributes. However, because of its more familiar SQL syntax and its ability to filter on all types (strings, numbers, booleans, dates), we suggest using the filters parameter.

facetFilters 매개변수를 사용하여 적중량을 필터링할 수 있습니다. 기능은 대부분 동일하며, 둘 다 특정 속성을 기준으로 레코드를 필터링합니다. 그러나 SQL 구문과 모든 유형(스트링, 숫자, 부울런, 날짜)을 필터링할 수 있는 기능 때문에 필터 매개 변수를 사용할 것을 제안한다.

optionalFilters

When using filters, you are telling the engine to return only those records that match the filter(s) specified in the search. With optionalFilters, you are telling the engine to return not only filter-matching records, but all records that match the query. The difference is that optional filtering puts filter-matching records at the top and all other query-matching records lower in the ranking order. Optional filters are mainly used for promoting.

필터를 사용할 때, 검색에서 오직 지정한 필터와 일치하는 레코드만 반환하도록 엔진에 지시합니다. 선택적 Filters를 사용하면 엔진에 필터 일치 레코드뿐만 아니라 쿼리와 일치하는 모든 레코드를 반환하도록 지시할 수 있습니다. 차이점은 선택적 필터링은 필터 일치 레코드를 맨 위에 배치하고 다른 모든 쿼리 일치 레코드는 순위 순서대로 더 낮게 배치한다는 것입니다. 선택적 필터는 주로 홍보에 사용됩니다.

_Tags

Algolia lets you add tags to each of your records thanks to the special attribute _tags. This reserved Algolia attribute automatically works as a filter without you having to set it as an attribute for faceting.

Therefore, we can leverage this attribute and tag books by categories or genre.

Algolia를 사용하면 _tags라는 특수 특성 덕분에 각 레코드에 태그를 추가할 수 있습니다. 이 예약된 Algolia 특성은 패싱을 위한 속성으로 설정할 필요 없이 자동으로 필터로 작동합니다.
따라서 우리는 이 속성을 활용하여 카테고리 또는 장르별로 책에 태그를 지정할 수 있습니다.

 

Note: _tags is a reserved word and so it is not searchable by default. 태그는 예약된 단어이므로 기본적으로 검색할 수 없습니다.

 

How to apply filtering to the Search UI(Search UI에 filtering 적용하는 방법)

The first step in filtering is to create filter attributes, and then to make sure every record is tagged appropriately. Once this is done, you’ll also want to make sure that your frontend UI accurately represents all filtering possibilities. You do this with facets (called Refinements in InstantSearch).

필터링의 첫 번째 단계는 필터 특성을 만든 다음 모든 레코드에 태그가 적절하게 지정되었는지 확인하는 것입니다. 이 작업이 완료되면 프런트엔드 UI가 모든 필터링 가능성을 정확하게 나타내는지 확인해야 합니다. 이 작업은 패싯(InstantSearch의 개선이라고 함)에서 수행합니다.

You’ll typically want to display all filtering categories (facets/refinements). Thus, if you have created two filters, Brand and Price Range, you’ll always want to see a list of brands and a price range slider for every query. The effect is that while the actual category values may change, the categories themselves will always be present. This is what we call static faceting. For example, a search for phones will return brands like Apple and Samsung, while a search for stereos will return Panasonic and Bose. So while the values may change, the brand facet/refinement is always present.

일반적으로 당신은 모든 필터링 categories(facets/수정)를 표시할 수 있습니다. 따라서 브랜드 및 가격 범위라는 두 가지 필터를 만든 경우 모든 쿼리에 대한 브랜드 목록과 가격 범위 슬라이더를 항상 볼 수 있습니다. 실제 categories 값은 변경될 수 있지만 범주 자체는 항상 존재합니다. 이것이 우리가 정적 패싱이라고 부르는 것입니다. 예를 들어, 전화기를 검색하면 애플과 삼성 같은 브랜드가 반환되고 스테레오를 검색하면 파나소닉과 보스가 반환된다. 따라서 가치가 변화할 수 있지만 브랜드 측면/개선은 항상 존재합니다.

 

 

Alternative benefits of filtering(필터링의 대체 이점)

Other Use Cases

The main use case for filtering is to enable users to refine their search with string categories or numeric ranges, and so on, thereby limiting the range of data that they search within.

There are other use cases for filters.

필터링의 주요 사용 사례는 사용자가 문자열 범주 또는 숫자 범위 등으로 검색을 세분화하여 검색할 데이터 범위를 제한하는 것입니다.
필터에 대한 다른 사용 사례도 있습니다.

  • Security-filtering: You can use filters as a security measure, where each user has access to only their own private data.
  • Geo-filtering: You can filter on the geo location of the user, if your index is geographically sensitive.
  • Filter Scoring: You can use filters for merchandising, to help promote some records over others. This is done by using filter scoring, where you can designate some filters as more important than others.
  • Query-Based Filtering: You can set up Rules that parse your users’ queries and use certain query terms as filters instead of search terms. For example, if a user types in a filter value - say, “red” - that term can be used as a filter instead of as a search term, thereby returning all red records. If the full query had been “red dress”, then the term “dress” would search only red records.

-보안 필터링: 각 사용자가 자신의 개인 데이터에만 액세스할 수 있는 보안 수단으로 필터를 사용할 수 있습니다.
-지역 필터링: 색인이 지리적으로 중요한 경우 사용자의 지역 위치를 필터링할 수 있습니다.
-필터 점수 매기기: 판매용 필터를 사용하여 일부 레코드를 다른 레코드보다 홍보할 수 있습니다. 이 작업은 필터 스코어링을 사용하여 수행되며, 여기서 일부 필터를 다른 필터보다 더 중요한 필터로 지정할 수 있습니다.
-쿼리 기반 필터링: 사용자의 쿼리를 구문 분석하고 검색어 대신 특정 쿼리 용어를 필터로 사용하는 규칙을 설정할 수 있습니다. 예를 들어, 사용자가 필터 값(예: "빨간색")을 입력하면 해당 용어를 검색어 대신 필터로 사용할 수 있으므로 빨간색 레코드를 모두 반환할 수 있습니다. 만약 전체 쿼리가 "빨간 드레스"였다면, "드레스"라는 용어는 빨간 레코드만 검색할 것이다.

 

 

728x90

'개발 > ALGOLIA' 카테고리의 다른 글

알고리아 Managing Results(3-27)  (0) 2022.03.05
알고리아 Managing Results(3-26)  (0) 2022.03.05
알고리아 Managing Results(3-24)  (0) 2022.03.04
알고리아 Managing Results(3-23)  (0) 2022.03.04
알고리아 Managing Results(3-22)  (0) 2022.03.04