Answer Process

The answer process allows answer engine plugins to work together to generate a customized list of answers for each user.

Overview of Steps

Here is an overview of the steps in the answer process:

  1. A user submits an answer query to Solve for All
  2. The following sets are computed:
  3. Content Recognizers in the set are executed, outputting recognition results
  4. Semantic Data Collections in the set are searched, outputting recognition results
  5. All recognition results are combined
  6. Triggers in the set are executed. Each Trigger outputs a Boolean flag indicating if the associated Answer Generators should be activated.
  7. Each Answer Generator (activated by a Trigger, activation keyword(s), activation code, or command line option) is executed, yielding a list of answers
  8. All answers are combined into a single list and post-processed
  9. The post-processed answer list is sorted
  10. The sorted answer list is sent to the user

Dataflow Diagram

The following diagram illustrates the data flow of the answer process:

Answer Process Dataflow

Notes Triggers and Answer Generators also receive the answer query and the Query Context as input. Triggers can activate one or more Answer Generators. The post-processing and sorting of answers is not shown above.

Detailed Description of Steps

Details on the execution of each step follow below.

1. A user submits an answer query to Solve for All

The user uses a web browser, browser extension, or mobile application to submit an answer request to Solve for All. The answer request may also contain the user's location, client metadata, and whether or not the query is a suggestion query. Some of this information is passed to the Query Context, which available to plugins.

2. Computation of Content Recognizer, Semantic Data Collection, and Trigger Sets

For each Answer Generator - Trigger Association the user has configured in his answer preferences, the set of Triggers and T set of potential Answer Generators Gp is computed by combining all the Triggers in the associations and all the Answer Generators in the associations. Additionally, the set of potential Answer Generators is augmented by the Answer Generators that are explicitly activated through activation keyword(s), an activation code, or the --g command-line option (see Configuring Activation).

Each Answer Generator and each Trigger optionally has a set of required Content Recognizers and a set of required Semantic Data Collections. Each Trigger in T contributes its required Content Recognizers to a set of Content Recognizers R, and contributes its required Semantic Data Collections to a set of Semantic Data Collections C. Similarly, each Answer Generator in Gp contributes its required Content Recognizers to R, and contributes its required Semantic Data Collections to C.

3. Content Recognizers are executed

All Content Recognizers in the set R are executed. Each Content Recognizer outputs a map from recognition keys (indicating some type of content was found) to data about the recognized content.

Content Recognizers are implemented by either looking in the query string for matches of regular expressions, or by running a user-supplied script written in Javascript.

For more information, see the Content Recognizer documentation.

4. Semantic Data Collections are searched

All Semantic Data Collections in the set C are searched. Each Semantic Data Collection specifies a query template for searching a collection of JSON documents indexed by Elasticsearch. The search results are transformed into a dictionary of recognition keys to data about recognized terms in the answer query.

For more information, see the Semantic Data Collection documentation.

5. All recognition results are combined

All dictionaries of recognition keys to data, which are output by executing the Content Recognizers in step 3, and by searching the Semantic Data Collections in step 4 are combined into a single dictionary. For an example of this, see Combined Recognition Results.

6. Triggers are executed

Each trigger in the set T is executed, with the Query Context and Combined Recognition Results as input, and a Boolean flag as output. The Boolean flag indicates whether an Answer Generator associated with the Trigger should be executed.

Most triggers are implemented by configuring a Simple Trigger to look for a recognition key that maps to a recognition result that has a high enough relevance. For more complex conditions, Triggers can also be implemented in Javascript.

For more information, see the Trigger documentation.

7. Activated Answer Generators are executed

For each of the Answer Generator - Trigger Associations the user has selected, if the Trigger activated in step 6, the Answer Generator is added to the set of activated Answer Generators.

The set of activated Answer Generators is augmented by those activated by activation keyword(s), an activation code, and the --g command-line option.

Once the set of activated Answer Generators is computed, all Answer Generators in the set are executed. Answer Generators may be implemented as URI templates, content templates, or Javascript scripts. Each Answer Generator outputs a list of answers. Each answer may be a link or inline content, and has a relevance score.

For more information, see the Answer Generator documentation.

8. All answers are combined into a single list and post-processed

All of the lists of answers output by the Answer Generators in step 7 are concatenated into a single list, then the list is post-processed so that:

  • Link answers with the same URI are de-duplicated. Solve for All chooses the link answer according to the sorting rules of step 9, selecting the top answer and discarding the rest.
  • Link answers that have URIs that can be embedded are converted to inline answers that embed the content. For more details, see the OEmbed spec. Other embeddings are courtesy of Noembed.

9. The post-processed answer list is sorted

The list of of answers output by step 3 are now sorted so that answers are ordered from most desirable to least desirable. The priority of each answer depends on these factors:

  • Answers created by Answer Generators activated by the --g option in the answer query take precedence over all other answers. If multiple Answer Generators are activated by --g, the ordering of the answers follows the order that the corresponding Answer Generator ID appears in the option value.
  • Answer activated by activation codes in the answer query take precedence over normal answers. If multiple activation codes are present, the answers produced by the corresponding Answer Generators will be ordered according to the order of the corresponding activation code in the answer query.
  • Answers produced by Answer Generators in Answer Generator - Trigger Associations selected by the user are ordered by their relevance; answers with higher relevance will appear before those with lower relevance.
  • If the preceding rules do not determine an ordering between two answers, inline answers are preferred over link answers.

10. The sorted answer list is sent to the user

Finally, the sorted answer list output by step 9 is sent back to the user's client, which displays the answers for the user to enjoy.