Page tree
Skip to end of metadata
Go to start of metadata


Quick Start

The following exercise builds on the Attivio Quick Start Tutorial and takes a closer look at building JSON REST API requests which include multi-level facets.

1. Deploy the Attivio Factbook Project

Open the Attivio Quick Start Tutorial in a new tab in your browser, follow the instructions to deploy the Factbook project, and return to this page when complete.

2. Create a REST request using Postman

    Download and install the free third-party Postman REST API client from https://www.getpostman.com/.

    In Postman, create a POST request with URL http://{server}:17000/rest/searchApi/search.

    Add basic authentication and headers as shown below:


    Paste the JSON request below in the request body section. Filters are added in this example for simplicity.

    {
      "workflow": "search",
      "query": "london",
      "queryLanguage": "simple",
      "locale": "en",
      "facets": [ "table(childFacet=country(childFacet=language))" ],
      "filters":["table:city"],
      "rows": 0,
      "fields": [ ".id", "title", "text", "date" ],
      "restParams": {  
        "highlight": [ "true" ]
        }
    }

    Click the Send button to post the request to the Attivio REST Query API endpoint.


    3. Response body

    The JSON response body should appear as below:

    {
        "totalHits": 3, //total documents matched
        "totalTime": 206,
        //These are the overall facets requested which contains buckets and children
        "facets": [						
            {
                "name": "table",
                "field": "table",
                "label": "Table",
                "count": 3,
    			//buckets are different values facet. In this case, we only see city because of request filters.
                "buckets": [
                    {
                        "value": "city",
                        "count": 3,
                        "filter": "table:FACET(city)",
    					//Level 2 Facets - country. The documents from table facet will be filtered based on country.
                        "children": {
                            "name": "country",
                            "field": "country",
                            "buckets": [
    							//first bucket value for country
                                {
                                    "value": "Canada",
                                    "count": 1,
                                    "filter": "AND(table:FACET(city), country:FACET(Canada))",  //documents containing table as city and country as Canada.
    								//Level 3 facets - language. The documents from table and country facets will be filtered again based on the language.
                                    "children": {
                                        "name": "language",
                                        "field": "language",
                                        "label": "Primary Language",
    									//different languages found in those documents.
                                        "buckets": [
                                            {
                                                "value": "Italian",
                                                "count": 1,
                                                "filter": "AND(table:FACET(city), country:FACET(Canada), language:FACET(Italian))" //documents containing table as city, country as Canada and language as Italian.
                                            }
                                        ]
                                    }
                                },
    							//Second bucket value for country
                                {
                                    "value": "South Africa",
                                    "count": 1,
                                    "filter": "AND(table:FACET(city), country:FACET(\"South Africa\"))",
                                    "children": {
                                        "name": "language",
                                        "field": "language",
                                        "label": "Primary Language",
                                        "buckets": [
                                            {
                                                "value": "English",
                                                "count": 1,
                                                "filter": "AND(table:FACET(city), country:FACET(\"South Africa\"), language:FACET(English))"
                                            }
                                        ]
                                    }
                                },
    							//Third bucket value for country
                                {
                                    "value": "United Kingdom",
                                    "count": 1,
                                    "filter": "AND(table:FACET(city), country:FACET(\"United Kingdom\"))",
                                    "children": {
                                        "name": "language",
                                        "field": "language",
                                        "label": "Primary Language",
                                        "buckets": [
                                            {
                                                "value": "English",
                                                "count": 1,
                                                "filter": "AND(table:FACET(city), country:FACET(\"United Kingdom\"), language:FACET(English))"
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        ],
        "facetFilters": [],
        "facetTime": 5,
        "highlightTime": 0,
        "resultTime": 1,
        "searchTime": 196
    }


    4. Experiment with different facet combinations as below

    You can create any number of such combinations with different facets.


    • Filter, discrete, schema

      "facets": [ "size(filter=small(\"size:>120\"), childFacet=table(childFacet=.fields))" ], 
    • Range, filter

      "facets": [ "size(range=(\"< 150 \",0,150), range = (\"> 150 \",150,600),sortBy=COUNT, primarySort=ASC, minBucketCount=1, childFacet=peeps(filter=Chinese(\"country:China\")))" ],
    • Filter, filter

      "facets": [ "peeps(filter=Chinese(\"country:China\"), childFacet=size(filter=small(\"size:>120\")))" ],
    • Schema, filter

      "facets": [ ".fields(maxBuckets=10, childFacet=peeps(filter=Chinese(\"country:China\")))" ],


    5. Reference for different types of facets

    See the Facets page for more details on the options available for facet requests.





    • No labels