Skip to content

Commit

Permalink
Merge pull request #1690 from Danielle9897/RDoc-2497-NodeJs-facets
Browse files Browse the repository at this point in the history
RDoc-2497 Indexes > Querying > Faceted search
  • Loading branch information
ppekrol authored Sep 11, 2023
2 parents 3941a39 + f655b05 commit a25d083
Show file tree
Hide file tree
Showing 20 changed files with 2,751 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
{
"Path": "how-to-perform-a-faceted-search.markdown",
"Name": "How to Perform a Faceted Search",
"Name": "Perform Faceted Search",
"DiscussionId": "73756544-0c4f-4d32-a074-d9292cbe4bdb",
"Mappings": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Perform a Faceted (Aggregated) Search

---

{NOTE: }

* A __Faceted Search__ provides an efficient way to explore and navigate through large datasets or search results.

* To make a faceted search,
a static-index must be defined for the fields you want to query and apply facets on.
Please refer to article __Query by Facets__ under [Indexes > Querying > Faceted search](../../../indexes/querying/faceted-search).

{NOTE/}

---

## Related Articles

### Session

- [How to Query](../../../client-api/session/querying/how-to-query)

### Indexes

- [Faceted Search](../../../indexes/querying/faceted-search)
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Session: Querying: How to Perform a Faceted (Aggregated) Search

To execute facet (aggregation) query using the session `query` method, use the `aggregateBy` or `aggregateUsing` methods. This will scope you to the aggregation query builder where you will be allowed to define single or multiple facets for the query using a straightforward and fluent API.

## Syntax

{CODE:java facet_1@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}

| Parameters | | |
| ------------- | ------------- | ----- |
| **facet** | FacetBase | `FacetBase` implementation defining the scope of the facet and its options (either `Facet` or `RangeFacet`) |
| **facets** | `FacetBase...` | Items containing `FacetBase` implementations |
| **builder** | `Consumer<IFacetBuilder<T>>` | Builder with a fluent API that constructs a `FacetBase` instance |
| **facetSetupDocumentId** | String | ID of a document containing `FacetSetup` |

### Facet & RangeFacet

{INFO:Facet vs RangeFacet}
`RangeFacet` allows you to split the results of the calculations into several ranges, in contrast to `Facet` where whole spectrum of results will be used to generate a single outcome.
{INFO/}

{CODE-TABS}
{CODE-TAB:java:Facet facet_7_3@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TAB:java:RangeFacet facet_7_4@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TAB:java:FacetAggregation facet_7_5@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TABS/}

### Builder

{CODE:java facet_7_1@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}

| Parameters | | |
| ------------- | ------------- | ----- |
| **path** | String | Points to the index field that should be used for operation (`byRanges`, `byField`) or to document field that should be used for aggregation (`sumOn`, `minOn`, `maxOn`, `averageOn`) |
| **fieldName** | String | Points to the index field that should be used for operation (`byRanges`, `byField`) or to document field that should be used for aggregation (`sumOn`, `minOn`, `maxOn`, `averageOn`) |
| **displayName** | String | If set, results of a facet will be returned under this name |
| **options** | `FacetOptions` | Non-default options that should be used for operation |

### Options

{CODE:java facet_7_2@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}

| Options | | |
| ------------- | ------------- | ----- |
| **termSortMode** | `FacetTermSortMode` | Indicates how terms should be sorted (`VALUE_ASC`, `VALUE_DESC`, `COUNT_ASC`, `COUNT_DESC`) |
| **includeRemainingTerms** | booelean | Indicates if remaining terms should be included in results |
| **start** | int | Used to skip given number of facet results in the outcome |
| **pageSize** | int | Used to limit facet results to the given value |

## Example I

{CODE-TABS}
{CODE-TAB:java:Java facet_2_1@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TAB-BLOCK:sql:RQL}
from index 'Camera/Costs'
select
facet(manufacturer),
facet(cost < 200, cost >= 200 AND cost < 400, cost >= 400 AND cost < 600, cost >= 600 AND cost < 800, cost >= 800),
facet(megapixels < 3, megapixels >= 3 AND megapixels < 7, megapixels >= 7 AND megapixels < 10, megapixels >= 10)
{CODE-TAB-BLOCK/}
{CODE-TABS/}

## Example II

{CODE-TABS}
{CODE-TAB:java:Java facet_3_1@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TAB-BLOCK:sql:RQL}
from index 'Camera/Costs'
select
facet(manufacturer),
facet(cost < 200, cost >= 200 AND cost < 400, cost >= 400 AND cost < 600, cost >= 600 AND cost < 800, cost >= 800),
facet(megapixels < 3, megapixels >= 3 AND megapixels < 7, megapixels >= 7 AND megapixels < 10, megapixels >= 10)
{CODE-TAB-BLOCK/}
{CODE-TABS/}

## Example III

{CODE-TABS}
{CODE-TAB:java:Java facet_4_1@ClientApi\Session\Querying\HowToPerformFacetedSearch.java /}
{CODE-TAB-BLOCK:sql:RQL}
from index 'Camera/Costs'
select facet(id('facets/CameraFacets'))
{CODE-TAB-BLOCK/}
{CODE-TABS/}

## Remarks

{WARNING `aggregateBy` only supports aggregation by a single field. If you want to aggregate by multiple fields, you need to emit a single field that contains all values. /}

## Related Articles

### Session

- [How to Query](../../../client-api/session/querying/how-to-query)

### Indexes

- [Faceted Search](../../../indexes/querying/faceted-search)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Perform a Faceted (Aggregated) Search

---

{NOTE: }

* A __Faceted Search__ provides an efficient way to explore and navigate through large datasets or search results.

* To make a faceted search,
a static-index must be defined for the fields you want to query and apply facets on.
Please refer to article __Query by Facets__ under [Indexes > Querying > Faceted search](../../../indexes/querying/faceted-search).

{NOTE/}

---

## Related Articles

### Session

- [How to Query](../../../client-api/session/querying/how-to-query)

### Indexes

- [Faceted Search](../../../indexes/querying/faceted-search)
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
{
"Path": "faceted-search.markdown",
"Name": "Faceted search",
"Name": "Faceted Search",
"DiscussionId": "471f8569-81ba-49c1-86fd-6c42c068deed",
"Mappings": [
{
Expand Down
Loading

0 comments on commit a25d083

Please sign in to comment.