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


The mode over a data set is the value in a set of values that occurs the most frequently. The mode for a field can be calculated using a facet request (as it is in general the first bucket returned in a facet when the facet is sorted by count).

View incoming links.


Example (Java)

// Create a client factory
AieClientFactory clientFactory = new DefaultAieClientFactory();
// create an attivio search client
SearchClient client = clientFactory.createSearchClient(host, port);
// Must set a workflow: default workflow is "search"

// Create the query request
QueryRequest request = new QueryRequest("*:*");
FacetRequest facetRequest = new FacetRequest("field_i");
facetRequest.setCalculateStatistics(false); // Don't need full set of facet statistics for the mode
facetRequest.setFacetFinder(false); // Disable facet finder (otherwise FacetRequest may be altered)
facetRequest.setMaxBuckets(1); // The mode will be the top bucket returned
facetRequest.setDistributedMaxBuckets(-1); // unlimited (prevent cutoff on sub dispatchers for 100% accurate result)
facetRequest.setSortOrder(FacetRequest.SortBy.COUNT, Sort.SortOrder.DESCENDING); // sort buckets by count descending
request.addFacet(facetRequest); // Add to our query request

// Get the query response
QueryResponse response =;
FacetResponse facet    = response.getFacet("field_i");
NumericBucket bucket   = (NumericBucket)facet.get(0);
Integer       mode     = (Integer)bucket.getSortValue();

// Display the mode
System.err.println("Facet Statistics:");
System.err.printf ("            Mode: %d\n", mode);
  • No labels