Commit 9bc12cad authored by Iker Hurtado's avatar Iker Hurtado
Browse files

Complex search logic implementation (12)

parent df619e2f
...@@ -7969,28 +7969,28 @@ ...@@ -7969,28 +7969,28 @@
let rootQueryObj = { 'bool' : {} }; let rootQueryObj = { 'bool' : {} };
rootQueryObj.bool.should = []; rootQueryObj.bool.should = [];
let queryObj = rootQueryObj.bool.should; let queryObj = rootQueryObj.bool.should;
let reduced = this.element.querySelector('#multiples-of-formula').checked;
formulas.forEach( formula => { formulas.forEach( formula => {
let pFormula; let pFormula;
let searchByElement = (formula.indexOf('0') >= 0); let searchByElement = (formula.indexOf('0') >= 0);
if (searchByElement){ // There are some element in the search expression if (searchByElement){ // There are some element in the search expression
/** TDO**/ /** TDO**/
pFormula = this._processFormula(formula, 'element-string'); let f = formula;
if (reduced) f = this._reduceFormula(formula, false);
pFormula = this._processFormula(f, 'element-string');
let tempQueryObj = { 'bool' : { 'must' : [] } }; let tempQueryObj = { 'bool' : { 'must' : [] } };
tempQueryObj.bool.must.push( tempQueryObj.bool.must.push(
this._getESOperatorMatch('formula_cell_terms', pFormula[0])); this._getESOperatorMatch(
(reduced ? 'formula_reduced_terms' : 'formula_cell_terms'), pFormula[0]));
tempQueryObj.bool.must.push( tempQueryObj.bool.must.push(
this._getESSimpleMatch('atom_labels_keyword', pFormula[1])); this._getESSimpleMatch('atom_labels_keyword', pFormula[1]));
queryObj.push(tempQueryObj); queryObj.push(tempQueryObj);
//queryObj.push(this._getESSimpleMatch('atom_labels_keyword', pFormula));
}else{ // Only formulas }else{ // Only formulas
if ( this.element.querySelector('#multiples-of-formula').checked ){ // reduced search if ( reduced ){ // reduced search
pFormula = this._reduceFormula(formula, false); pFormula = this._reduceFormula(formula, false);
queryObj.push(this._getESSimpleMatch('formula_reduced_keyword', pFormula)); queryObj.push(this._getESSimpleMatch('formula_reduced_keyword', pFormula));
}else{ }else{
......
...@@ -362,28 +362,28 @@ class NewSearchMod { ...@@ -362,28 +362,28 @@ class NewSearchMod {
let rootQueryObj = { 'bool' : {} }; let rootQueryObj = { 'bool' : {} };
rootQueryObj.bool.should = []; rootQueryObj.bool.should = [];
let queryObj = rootQueryObj.bool.should; let queryObj = rootQueryObj.bool.should;
let reduced = this.element.querySelector('#multiples-of-formula').checked;
formulas.forEach( formula => { formulas.forEach( formula => {
let pFormula; let pFormula;
let searchByElement = (formula.indexOf('0') >= 0); let searchByElement = (formula.indexOf('0') >= 0);
if (searchByElement){ // There are some element in the search expression if (searchByElement){ // There are some element in the search expression
/** TDO**/ /** TDO**/
pFormula = this._processFormula(formula, 'element-string'); let f = formula;
if (reduced) f = this._reduceFormula(formula, false);
pFormula = this._processFormula(f, 'element-string');
let tempQueryObj = { 'bool' : { 'must' : [] } }; let tempQueryObj = { 'bool' : { 'must' : [] } };
tempQueryObj.bool.must.push( tempQueryObj.bool.must.push(
this._getESOperatorMatch('formula_cell_terms', pFormula[0])); this._getESOperatorMatch(
(reduced ? 'formula_reduced_terms' : 'formula_cell_terms'), pFormula[0]));
tempQueryObj.bool.must.push( tempQueryObj.bool.must.push(
this._getESSimpleMatch('atom_labels_keyword', pFormula[1])); this._getESSimpleMatch('atom_labels_keyword', pFormula[1]));
queryObj.push(tempQueryObj); queryObj.push(tempQueryObj);
//queryObj.push(this._getESSimpleMatch('atom_labels_keyword', pFormula));
}else{ // Only formulas }else{ // Only formulas
if ( this.element.querySelector('#multiples-of-formula').checked ){ // reduced search if ( reduced ){ // reduced search
pFormula = this._reduceFormula(formula, false); pFormula = this._reduceFormula(formula, false);
queryObj.push(this._getESSimpleMatch('formula_reduced_keyword', pFormula)); queryObj.push(this._getESSimpleMatch('formula_reduced_keyword', pFormula));
}else{ }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