Commit e8d7351a authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added support for formula search for the new query optimade translation function.

parent 5714d658
Pipeline #93389 skipped with stage
This diff is collapsed.
......@@ -85,7 +85,7 @@ class SearchBox{
let query = [...this.searchQuery];
let types = [...this.queryTypes];
// For combining elements/formules connected by AND into a single list
// For combining elements/formulas connected by AND into a single list
function combineANDIn(query, types) {
const newQuery = []
const newTypes = []
......@@ -99,27 +99,23 @@ class SearchBox{
const q3 = query[i+2];
const t3 = types[i+2];
if (q2 === "AND" && q0 !== "NOT") {
if (
((t1 === "E" || t1 === "EL") && (t3 === "E" || t3 === "EL" )) ||
((t1 === "F" && t3 === "F")
) {
let active = true
let joined = [q1, q3]
i = i + 3
while(active) {
const q4 = query[i];
const t4 = types[i];
const q5 = query[i+1];
const t5 = types[i+1];
if (q4 === "AND" && (t5 === "E" || t5 === "EL" )) {
joined.push(q5)
i += 2
} else {
active = false
newQuery.push(joined.join(", "))
newTypes.push("EL")
}
if (((t1 === "E" && t3 === "E") || (t1 === "F" && t3 === "F")) && q2 === "AND" && q0 !== "NOT") {
let active = true
let type = t3
let joined = [q1, q3]
i = i + 3
while(active) {
const q4 = query[i];
const t4 = types[i];
const q5 = query[i+1];
const t5 = types[i+1];
if (q4 === "AND" && t5 === type) {
joined.push(q5)
i += 2
} else {
active = false
newQuery.push(joined.join(", "))
newTypes.push(type)
}
}
} else {
......@@ -404,7 +400,7 @@ class SearchBox{
for (let i=0; i < query.length; ++i) {
let q = query[i];
let t = types[i];
if (t === "E" || t === "EL") {
if (t === "E") {
if (allowOtherElements) {
q = "elements HAS ALL " + q
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment