A plugin for Elasticsearch, which implements the concept of information retrieval based on quantum logic.
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:
which should be equivalent to:
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.
- Install Elasticsearch 7.10.2. This plugin might not work for earlier or later releases or it needs to be adjusted.
- Download this plugin's
.zipfile and place it into a directory of your choice. - From the
bindirectory within your Elasticsearch download, runelasticsearch-plugin install <path to the .zip file>. - 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. - Now you can run Elasticsearch:
elasticsearch. The pluginsearch-cqqlwill be loaded automatically after loading all the other, regular modules.
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.
{
"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
}
}
}
]
}
}
}CQQL-ES as a whole is published under the GNU GENERAL PUBLIC LICENSE Version 3 (GPL).
- Matheclipse (Symja) is published under the GNU GENERAL PUBLIC LICENSE Version 3 (GPL).
- All other files are published under the Apache License, Version 2.0.
- As soon as there is a stable release of Symja, the
gradle.buildfile 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/boolneed to be implemented inCommutingQuantumQueryBuilder(this project uses a version from 2021/11/12). - A new
Similarityapproach should be implemented.