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

Changed the behaviour of the formula search from CONTAINS to HAS ANY/HAS ONLY.

parent f2fdfd25
Pipeline #92575 skipped with stage
This diff is collapsed.
window.nomadEnv = {
apiRoot: "https://nomad-lab.eu/dev/nomad/enc-search/api/encyclopedia/",
//apiRoot: "https://nomad-lab.eu/dev/nomad/enc-search/api/encyclopedia/",
//apiRoot: "https://nomad-lab.eu/prod/rae/api/encyclopedia/",
//apiRoot: "http://localhost:8000/fairdi/nomad/latest/api/encyclopedia/",
apiRoot: "http://localhost:8000/fairdi/nomad/latest/api/encyclopedia/",
keycloakBase: 'https://nomad-lab.eu/fairdi/keycloak/auth/',
keycloakRealm: 'fairdi_nomad_test',
keycloakClientId: 'nomad_gui_dev'
......
......@@ -161,7 +161,7 @@ class SearchBox{
}else{ // Formula
let formula = new Formula(item);
optimadeQuery += formula.getOptimadeInclusiveSubquery();// optimadeQuery += ` formula="${this.searchQuery[i]}"`
optimadeQuery += formula.getOptimadeSubquery(allowOtherElements);// optimadeQuery += ` formula="${this.searchQuery[i]}"`
}
});
......@@ -169,7 +169,9 @@ class SearchBox{
// if (subquery.length === 1 && !isElement(subquery[0])){ // Only one formula
if (!isElement(subquery[0])){ // formula(s)
optimadeQuery += `formula="${subquery[0]}"`;
//optimadeQuery += `formula="${subquery[0]}"`;
let formula = new Formula(subquery[0]);
optimadeQuery += formula.getOptimadeSubquery(allowOtherElements);
}else{ // Several items, they all should be elements
optimadeQuery += getOptimadeExclusiveANDSubquery(subquery);
......@@ -412,25 +414,16 @@ class Formula{
return map;
}
getOptimadeInclusiveSubquery(){
let optSubquery = '';
let first = true;
getOptimadeSubquery(allowOtherElements) {
const fragments = []
this.formulaMap.forEach( (number, element)=> {
console.log(element, number);
if (first) first = false;
else optSubquery += ' AND ';
let token = element + (number === 1 ? '' : +number);
optSubquery += `formula CONTAINS "${token}"`;
});
return optSubquery;
const fragment = '"' + element + (number === 1 ? '' : +number) + '"';
fragments.push(fragment)
})
return 'formula HAS ' + (allowOtherElements ? 'ANY ' : 'ONLY ') + fragments.join(', ')
}
/*
getReducedFormula(getTokens = true){
let counter = 0;
......
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