Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
encyclopedia-gui
Commits
deefa514
Commit
deefa514
authored
Oct 16, 2018
by
Iker Hurtado
Browse files
Complex search logic implementation (7)
parent
ae5096d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
client/bundle.js
View file @
deefa514
...
...
@@ -7920,6 +7920,36 @@
_getESQueryFromSearchQuery
(
searchQuery
,
queryTypes
){
let
formulas
=
[];
let
parFormulas
=
[];
let
openIndex
=
-
1
;
searchQuery
.
forEach
(
(
item
,
i
)
=>
{
if
(
queryTypes
[
i
]
===
'
F
'
){
addItem
(
(
openIndex
>
0
?
parFormulas
:
formulas
),
i
,
searchQuery
,
queryTypes
);
}
else
if
(
searchQuery
[
i
]
===
'
(
'
)
openIndex
=
i
;
else
if
(
searchQuery
[
i
]
===
'
)
'
){
//prodQuery.push(searchQuery.slice(openIndex+1, i), queryTypes.slice(openIndex+1, i) );
openIndex
=
-
1
;
}
});
console
.
log
(
formulas
,
parFormulas
);
function
addItem
(
formulas
,
i
,
searchQuery
,
queryTypes
){
if
(
i
===
0
||
searchQuery
[
i
-
1
]
===
'
(
'
){
formulas
.
push
(
item
);
}
else
{
if
(
searchQuery
[
i
-
1
]
===
'
OR
'
){
formulas
.
push
(
item
);
}
else
if
(
searchQuery
[
i
-
1
]
===
'
AND
'
){
formulas
.
push
(
formulas
.
pop
()
+
item
);
}
}
}
}
_getESQueryFromSearchQuery_otherElements
(
searchQuery
,
queryTypes
){
// Query structure analysis - looking for parentheses (only one level supported)
...
...
@@ -7932,7 +7962,7 @@
for
(
let
i
=
0
;
i
<
searchQuery
.
length
;
i
++
)
{
if
(
searchQuery
[
i
]
===
'
(
'
)
openIndex
=
i
;
else
if
(
searchQuery
[
i
]
===
'
)
'
){
prodQuery
.
push
(
this
.
_getESQueryFromSearchQuery
(
prodQuery
.
push
(
this
.
_getESQueryFromSearchQuery
_otherElements
(
searchQuery
.
slice
(
openIndex
+
1
,
i
),
queryTypes
.
slice
(
openIndex
+
1
,
i
)));
prodTypes
.
push
(
'
Q
'
);
openIndex
=
-
1
;
...
...
@@ -7942,7 +7972,7 @@
}
}
console
.
log
(
'
prodQuery
'
,
prodQuery
,
prodTypes
);
return
this
.
_getESQueryFromSearchQuery
(
prodQuery
,
prodTypes
);
return
this
.
_getESQueryFromSearchQuery
_otherElements
(
prodQuery
,
prodTypes
);
}
else
{
// BASE CASE: there is no parentheses
...
...
client/src/search-mod/NewSearchMod.js
View file @
deefa514
...
...
@@ -313,6 +313,36 @@ class NewSearchMod {
_getESQueryFromSearchQuery
(
searchQuery
,
queryTypes
){
let
formulas
=
[];
let
parFormulas
=
[];
let
openIndex
=
-
1
;
searchQuery
.
forEach
(
(
item
,
i
)
=>
{
if
(
queryTypes
[
i
]
===
'
F
'
){
addItem
(
(
openIndex
>
0
?
parFormulas
:
formulas
),
i
,
searchQuery
,
queryTypes
);
}
else
if
(
searchQuery
[
i
]
===
'
(
'
)
openIndex
=
i
;
else
if
(
searchQuery
[
i
]
===
'
)
'
){
//prodQuery.push(searchQuery.slice(openIndex+1, i), queryTypes.slice(openIndex+1, i) );
openIndex
=
-
1
;
}
});
console
.
log
(
formulas
,
parFormulas
);
function
addItem
(
formulas
,
i
,
searchQuery
,
queryTypes
){
if
(
i
===
0
||
searchQuery
[
i
-
1
]
===
'
(
'
){
formulas
.
push
(
item
);
}
else
{
if
(
searchQuery
[
i
-
1
]
===
'
OR
'
){
formulas
.
push
(
item
);
}
else
if
(
searchQuery
[
i
-
1
]
===
'
AND
'
){
formulas
.
push
(
formulas
.
pop
()
+
item
);
}
}
}
}
_getESQueryFromSearchQuery_otherElements
(
searchQuery
,
queryTypes
){
// Query structure analysis - looking for parentheses (only one level supported)
...
...
@@ -325,7 +355,7 @@ class NewSearchMod {
for
(
let
i
=
0
;
i
<
searchQuery
.
length
;
i
++
)
{
if
(
searchQuery
[
i
]
===
'
(
'
)
openIndex
=
i
;
else
if
(
searchQuery
[
i
]
===
'
)
'
){
prodQuery
.
push
(
this
.
_getESQueryFromSearchQuery
(
prodQuery
.
push
(
this
.
_getESQueryFromSearchQuery
_otherElements
(
searchQuery
.
slice
(
openIndex
+
1
,
i
),
queryTypes
.
slice
(
openIndex
+
1
,
i
)));
prodTypes
.
push
(
'
Q
'
);
openIndex
=
-
1
;
...
...
@@ -335,7 +365,7 @@ class NewSearchMod {
}
}
console
.
log
(
'
prodQuery
'
,
prodQuery
,
prodTypes
);
return
this
.
_getESQueryFromSearchQuery
(
prodQuery
,
prodTypes
);
return
this
.
_getESQueryFromSearchQuery
_otherElements
(
prodQuery
,
prodTypes
);
}
else
{
// BASE CASE: there is no parentheses
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment