The Query Context

Overview

All Answer Engine Plugins receive as input the Query Context which contains information about the circumstances in which the answer query was made. For example, the Query Context contains the user's locale and information about the application used to make the answer query. This information can be helpful to customize an Answer Engine Plugin's output to suit the user.

Common Properties

The Query Context always contains these properties:

Name Example Value Description
isSuggestionQuery false True if the answer query originates from a suggestion request (autocompletion of a partial query)
isContentDisplayable false True if the client is capable of display inline content when it receives the answers. This flag is typically true for non-suggestion queries, and false for suggestion queries. However, it is possible to view inline content in response to suggestion queries on the main page of Solve for All, and in this case, this flag is true.
fullSanitizedQuery "a long, long, ... time ago" The query, before truncation, stripped of activation codes and option flags. (The original query is truncated to 80 characters.)
tokenizedQuery {"weather" : [0], "london", [1]} A dictionary from tokens in the answer query to an array of token positions. The answer query is tokenized by splitting on non-Unicode letter boundaries (spaces, punctuation, etc.). Token are lower-cased using English language rules and used as keys into the dictionary. The values of the dictionary are zero-based token positions in the original answer query.
embedded false True if the answer results are to be embedded in inner frames, as in the displaying them in solveforall.com itself
client.kind "web" The kind of client displaying the results. Either "web" or "chrome-extension", more kinds to follow.
client.version "unknown" The version of the client. May be "unknown".
client.src "answers_page" The source of the query in the client's UI. When client.kind is "web", one of:
  • "main_page": The search form on the main page of solveforall.com
  • "answers_page": The search from at the top of the answers page, usually used after a query from the main page sends the user to the answers page.
  • "top_bar": The search form at the top of one of the other pages of solveforall.com
  • "opensearch": A search input in the user's browser that uses the OpenSearch format to submit the query. This is the omnibox in Chrome and the search box in Firefox.
  • "chrome_extension_omnibox": The omnibox of a browser that has the Solve for All Chrome extension installed. Happens when the user types s, followed by a tab, then the answer query.
  • "idea_plugin": Selected text in a file opened by the Solve for All integration plugin to an IDEA IDE (IntelliJ, RubyMine, WebStorm, PyCharm, etc.)
When client.kind is "chrome-extension", one of:
  • "popup": The popup displayed when the user selects the Solve for All extension icon
  • "selection-auto": Selected text on a page that is sent to Solve for All automatically
  • "selection-context-menu": Selected text on a page that is sent after the user opens a context menu and selects the option to search for the selected text using Solve for All
  • "selection-keyboard-command": Selected text on a page that is sent after the user selects some text and types the keyboard shortcut (Control-Shift-A) to search using Solve for All
requestHeaders["accept-language"] "en-US,en;q=0.8" The Accept-Language HTTP request header
locale.fullText "en-US" The user's locale, in BCP 47 format
locale.language "en" The ISO 639-1 code of the locale
locale.country "US" The ISO 3166-1 country code of the language
locale.variant "Windows 7" The variant of the locale
grantedPermissions ["user.emailAddresses", "trusted_content"] The set of names of permissions granted to the Answer Generator
settings {"languageVersion": "6.0.0", "showSourceCode": "false"} User-specific settings set by the user in the user preferences page for the Answer Generator. See User Preferences Pages.
developerSettings {"googleApiKey": "AB396-22GB3321-MI73"} Settings set by you, available to all your Answer Generators. See Developer Settings.

Extended Properties for Answer Generators

Answer Generators receive an enhanced version of the Query Context containing more information, depending on the permissions granted by the user. For example, the Query Context given to an Answer Generator may contain information about the user and the user's location.

The full list of extended properties is listed below:

Name Example Value Required Permission Description
user.firstName "Jeff" user.first_name.read or user.full_name.read The first name of the user
user.lastName "Smith" user.full_name.read The last name of the user
user.username "pwnuser" user.username.read The username of the user
user.physicalAddresses [{"addressLine1" : "1751 Forest Road", "addressLine1" : "UNIT 2", "city" : "Dallas", "region" : {"name": "Texas", "abbreviation": "TX"}, "postalCode": "75220", "country": {"name": "United States"}, "usageType": "personal"] physical_address.coarse.read for all properties except for addressLine1 and addressLine2

physical_address.full.read for all properties
The physical addresses of the user
user.emailAddresses [{"address" : "pwnuser@solveforall.com", "usageType" : "work"}] email_address.read The email addresses of the user
user.phoneNumbers [{"phoneNumber" : ""858-555-9225"", "usageType" : "personal"}] phone_number.read The phone numbers of the user
requestHeaders["user-agent"] "Mozilla/5.0 (X11; Linux x86_64) Ubuntu/12.10 Chrome/22.0.1229.94" http_headers.user_agent.read The User-Agent HTTP request header
pageUri "http://www.yahoo.com/article/36" current_page_uri.read The URI of the page on which the user selected the answer query. May not be available if the user entered the answer query manually.
location.lat 37.782823 location.read The latitude in degrees of the user's location
location.lng -122.409427 location.read The longitude in degrees of the user's location
location.alt 5.3 location.read The altitude above sea level, in meters, of the user's location

Usage Types

Each piece of contact information above has a usage type associated with it, which can be one of the following:

  • personal
  • work
  • school

Debugging

To see the Query Context, enter ??debug at the beginning or end of a query. The Solve for All Debug Answer Generator will be activated and you can view the Query Context there.