Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Within the top level query JSON object there is a query field "qt" that is an array of query term objects. Query term objects are described below and allow the following query types:

These terms can then be combined in an arbitrary boolean expression (with the operators AND, OR, NOT and parantheses) using the (case insensitive) "logic" field of the top level object, where the different terms are denoted by their index in the array (counting from 1). For example:

...

In the "dot notation" used to represent query objects as URL parameters in "GET" requests, the different "qt" terms are represented as "qt[INF:0]", "qt[INF:1]", etc (ie indexed from 0, unlike the "logic" string).

...

For example (using dot notation), qt[INF:0].etext="barack obama" will match on documents containing "barack obama" but not documents containing only (eg) "president obama", "barack 'barry' obama" etc.

...

For example, { "qt": [ "ftext": "barack obama" ] } will match on any documents containing either "barack" or "obama", with documents containing both scored more highly. { "qt": [ "ftext": "+barack +obama" ] } requires both be present (but not necessarily in the same phrase), and { "qt": [ "ftext": "'barack obama'" ] } is equivalent to the "etext" query described above.

Other examples:

  • qt[INF:0].ftext="+obama -palin": documents containing the word "Obama" but not containing the word "Palin"
  • qt[INF:0].ftext="title:\"palin\"": documents with the word "Palin" in the title.

...

In both cases, the optional "entityOpt.expandAlias" boolean term will allow matching not just on the entity but also on common aliases. This will tend to have the effect of matching on more documents, some of which will be false positives however. This query type is also slower.

Some examples:

  • qt[INF:0].entity="facebook/company": will match on documents containing references to the company Facebook, but not the technology.
  • qt[INF:0].entityValue="facebook"&qt[INF:0].entityType="company": equivalent to the above
  • qt[INF:0].entityValue="facebook": will match on both uses of the term Facebook
  • { "qt": [ { "entity": "barack obama/president", "entityOpt": { "expandAlias": true } } ] }: will match on documents containing references to Barack Obama, but also other common text strings such as "Barry Obama", "President Obama" etc.

...

The "dist" string is a distance in the format "<distance><unit>" where <distance> is an integer or floating point number, and unit is one of "m" (miles), "km" (kilometers), "nm" (nautical miles).

Examples:

  • qt[INF:0].geo.centerll="40.12,-71.34"&qt[INF:0].geo.dist="100km": within 100km of the specified lat/long.
  • { "qt": [ { "geo": { "centerll": "40.12,-71.34", "dist": "100" } } ] }: uses the default unit (km), ie is the same query as above.
  • qt[INF:0].geo.minll="(4.1,-171.34)"&qt[INF:0].geo.maxll="40.12,-71.34": bounding box showing lat/long format with and without parantheses.

...

  • { "qt": [ { "time": { "min": "1284666757164", "max": "now" } } ] }: from 16 Sep 2010 until now.
  • qt[INF:0].time.min="now": any time in the future.
  • qt[INF:0].time.max="20100201": any time before 1 Feb 2010.
  • { "qt": [ { "time": { "min": "02/10/2000", "max": "10 Feb 2001 13:00:00" } } ] }: from 10 Feb 2000 until 10 Feb 2001 at 1pm.

...

As can be seen from the above code block, the event query term is a composite of other query term types (INF:free text, INF:exact text and INF:entity terms for "entity1" and "entity2"; also INF:temporal and INF:geospatial).

Some things to note while performing entity queries:

...

  • Using the "logic" field as described INF:above under "Overview of querying". This is the standard way of combining separate queries.
  • In addition, within a single query term multiple elements of different types can be merged into a single object - this has the effect of ANDing them together. For example:
    • { "qt": [ { "entity": "barack obama/person", "time": { "min": "1284666757164", "max": "now" } } ] }: documents containing the entity Barack Obama, from 16 Sep 2010 until now.
    • qt[INF:0].etext="apple"&qt[INF:0].ftext="pair": this is equivalent to qt[INF:0].etext="apple"&qt[1].ftext="pair"&logic="1 and 2"

...