Elasticsearch extensions for QPL - Operators

From wiki.searchtechnologies.com
Jump to: navigation, search

For Information on Aspire 3.1 Click Here

This Page is Locked - Content no longer maintained - See QPL for the latest information.
Enterprise Add-On Feature

BETWEEN operator

The QPL plug-in for elasticsearch comes with a "between" operator which can be used to find query expressions which occur between two tags. The "between" operator can be used to create true XML searching within elasticsearch.

The basic structure of the between operator is as follows:

 {
   "between":{
     "start_tag":{
       "span_term" : { "xml" : "<content>" }
     },
     "end_tag":{
       "span_term" : { "xml" : "</content>" }
     },
     "query":{
       "span_or" : {
         "clauses" : [
           { "span_term" : { "xml" : "washington" } },
           { "span_term" : { "xml" : "adams" } },
           { "span_term" : { "xml" : "jefferson" } }
         ]
       }
     },
     "not_query":{
       "span_term" : { "xml" : "president" }
     }
   }
 }

Note that the contents of the arguments must be Spanning-type queries, which can include:

Technically, the arguments could also be Span Near or Span Not queries, but these scenarios are not well tested.

Other elements accepted:

  • "boost" - to set the boost value for documents which match this expression
    • Note that the score returned by Between is fixed for all queries, regardless of the scores of its operands.
    • This may be changed in the future
  • "_name" - to specify an elasticsearch named query


SPAN AND operator

The Span AND operator is a special operator intended to be used inside of the between operator when an AND() condition is required. Other operators (near, before) can not be used because they require proximity windows and return the wrong set of spans.

Span AND returns all combinations of spans which include all of its operands, so that those which are wholly between the start and end tag of a parent between operator can survive.

 {
   "span_and" : {
     "clauses" : [
       { "span_term" : { "field" : "value1" } },
       { "span_term" : { "field" : "value2" } },
       { "span_term" : { "field" : "value3" } }
     ]
   }
 }


Other elements accepted:

  • "boost" - to set the boost value for documents which match this expression
    • Note that the score returned by Span AND is fixed for all queries, regardless of the scores of its operands.
    • This may be changed in the future
  • "_name" - to specify an elasticsearch named query