Commands: Querying: How to work with Facet query?
There are two methods that allow you to send a Facet query to a database:
- GetFacets
- GetMultiFacets
GetFacets
There are few overloads for the GetFacets method and the main difference between them is a source of the facets. In one facets are passed as a parameter, in the other user must provide a key
to a facet setup
document.
Syntax
curl \
http://{serverName}/databases/{databaseName}/facets/{indexName}? \
&facetDoc={facetSetupDoc} \
&facetStart={start} \
&facetPageSize={pageSize} \
&facets={facets}
[Other indexQuery parameters] \
-X GET
curl \
http://{serverName}/databases/{databaseName}/facets/{indexName}? \
&facetStart={start} \
&facetPageSize={pageSize} \
[Other indexQuery parameters] \
-X POST \
-d @facets.txt
Request
Method |
Description |
GET |
serialized facets length < 1024 |
PUT |
serialized facets length > 1024 (pass facets as payload) |
Payload |
Facets data (for GET only) |
Query parameter |
Required |
Description |
indexName |
Yes |
A name of an index to query |
facets |
Yes |
Serialized list of facets required to perform a facet query (mutually exclusive with facetSetupDoc ). |
facetSetupDoc |
Yes |
Document key that contains predefined FacetSetup (mutually exclusive with facets ). |
start |
No |
number of results that should be skipped. |
pageSize |
No |
maximum number of results that will be retrieved. |
Response
Status code |
Description |
200 |
OK |
Return Value |
Description |
FacetResults |
Facet query results containing query Duration and a list of Results - one entry for each term/range as specified in FacetSetup document or passed in parameters. |
GetMultiFacets
Sending multiple facet queries is achievable by using /facets/multisearch
endpoint.
Syntax
curl \
http://{serverName}/databases/{databaseName}/facets/multisearch \
-X POST \
-d @facets.txt
Request
Response
Status code |
Description |
200 |
OK |