Skip to content

A plugin for Elasticsearch, which implements the concept of information retrieval based on quantum logic.

License

Notifications You must be signed in to change notification settings

TiMauzi/CQQL-ES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

CQQL-ES

A plugin for Elasticsearch, which implements the concept of information retrieval based on quantum logic.

Concept

This plugin was created in the context of a Bachelor's thesis at Brandenburg University of Technology Cottbus-Senftenberg (BTU). The idea of the quantum-based query language CQQL is invented in I. Schmitt. "QQL: A DB&IR Query Language". In: The VLDB Journal 17.1 (Special Issue Paper) (2008), pp. 39–56. DOI: 10.1007/s00778-007-0070-1.

The problem with e.g. BooleanQuery is that there are some flaws in the logical behavior from a theoretical perspective. Assume the following query in logical form:

\textrm{fox}\wedge\left(\textrm{eagle}\vee\textrm{crocodile}\right)

which should be equivalent to:

\left(\textrm{fox}\wedge\textrm{eagle}\right)\vee\left(\textrm{fox}\wedge\textrm{crocodile}\right)

due to distributivity law. However, this law is one of the rules which—generally—do not apply to Elasticsearch's standard BooleanQuery, where each of the queries above yields a different result.

The CommutingQuantumQuery provided by CQQL-ES fixes inconsistencies like these by first transforming all input queries into equivalent representations according to the definition of Boolean Algebras. Thus, logically equivalent queries actually result in the same output.

Installing the Plugin

  1. Install Elasticsearch 7.10.2. This plugin might not work for earlier or later releases or it needs to be adjusted.
  2. Download this plugin's .zip file and place it into a directory of your choice.
  3. From the bin directory within your Elasticsearch download, run elasticsearch-plugin install <path to the .zip file>.
  4. In a warning, you will be asked to give additional permissions. Confirm with y. This plugin uses Symja which needs access to your file system to store temporary files.
    Note: The installation of the plugin might fail if the confirmation happens too quickly. In that case, try repeating the process from step 3 on.
  5. Now you can run Elasticsearch: elasticsearch. The plugin search-cqql will be loaded automatically after loading all the other, regular modules.

Using the Plugin

The plugin uses an approach similar to Elasticsearch's bool query. You simply use the keyword commuting_quantum in place of bool. Note that there is a must, should, must_not, but no filter occurence type. Also note that currently there are only the options to use other commuting_quantum queries, or match/term/match_all/match_none queries. Other (atomic) query types are not yet implemented.

Example

{
  "query": {
    "commuting_quantum": {
      "should": [
        {"match": {"text": "fox"}},
        {
          "commuting_quantum":
          {
            "must": [
              {"match": {"text": "eagle"}},
              {"match": {"text": "crocodile"}}
            ]
          }
        }
      ]
    }
  }
}

It is also possible to add weights (preferably between 0 and 1) to conditions:

{
    "query": {
      "commuting_quantum": {
        "must": [
          {
            "match" : {
              "text" : "fox"
            }
          },
          {
            "match" : {
              "text" : {
                "query": "crocodile",
                "boost": 0.4
              }
            }
          }
        ]
      }
    }
}

License

CQQL-ES as a whole is published under the GNU GENERAL PUBLIC LICENSE Version 3 (GPL).

TODO

  • As soon as there is a stable release of Symja, the gradle.build file might download it directly instead of using a local distribution.
  • Other atomic queries (or queries that ought to be treated as such), e.g. BooleanQuery/bool need to be implemented in CommutingQuantumQueryBuilder (this project uses a version from 2021/11/12).
  • A new Similarity approach should be implemented.

About

A plugin for Elasticsearch, which implements the concept of information retrieval based on quantum logic.

Topics

Resources

License

Stars

Watchers

Forks

Languages