Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
778b1793
Commit
778b1793
authored
Jul 21, 2014
by
Ujvari Gergely
Committed by
gergely-ujvari
Jul 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement 'any' field processing
parent
0b15198a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
20 deletions
+31
-20
searchfilters.coffee
h/static/scripts/searchfilters.coffee
+21
-8
services.coffee
h/static/scripts/services.coffee
+3
-4
streamsearch.coffee
h/static/scripts/streamsearch.coffee
+7
-8
No files found.
h/static/scripts/searchfilters.coffee
View file @
778b1793
...
...
@@ -122,10 +122,12 @@ class SearchFilter
#
# options: backend specific options
# options.es: elasticsearch specific options
# options.es.query_type : can be: simple, query_string, match
# options.es.query_type : can be: simple, query_string, match
, multi_match
# defaults to: simple, determines which es query type to use
# options.es.cutoff_frequency: if set, the query will be given a cutoff_frequency for this facet
# options.es.and_or: match queries can use this, defaults to and
# options.es.and_or: match and multi_match queries can use this, defaults to and
# options.es.match_type: multi_match query type
# options.es.fields: fields to search for in multi-match query
# }
# The models is the direct output from visualsearch
class
QueryParser
...
...
@@ -182,6 +184,18 @@ class QueryParser
case_sensitive
:
true
and_or
:
'and'
operator
:
'ge'
any
:
exact_match
:
false
case_sensitive
:
false
and_or
:
'and'
path
:
[
'/quote'
,
'/tags'
,
'/text'
,
'/uri'
,
'/user'
]
options
:
es
:
query_type
:
'multi_match'
match_type
:
'cross_fields'
and_or
:
'and'
fields
:
[
'quote'
,
'tags'
,
'text'
,
'uri'
,
'user'
]
parseModels
:
(
models
)
->
# Cluster facets together
...
...
@@ -197,13 +211,12 @@ class QueryParser
populateFilter
:
(
filter
,
query
)
=>
# Populate a filter with a query object
for
category
,
value
s
of
query
for
category
,
value
of
query
unless
@
rules
[
category
]
?
then
continue
unless
values
.
length
then
continue
terms
=
value
.
terms
unless
terms
.
length
then
continue
rule
=
@
rules
[
category
]
unless
angular
.
isArray
values
values
=
[
values
]
# Now generate the clause with the help of the rule
exact_match
=
if
rule
.
exact_match
?
then
rule
.
exact_match
else
true
...
...
@@ -214,7 +227,7 @@ class QueryParser
if
and_or
is
'or'
val_list
=
''
first
=
true
for
val
in
value
s
for
val
in
term
s
unless
first
then
val_list
+=
','
else
first
=
false
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
val_list
+=
value_part
...
...
@@ -226,7 +239,7 @@ class QueryParser
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
if
exact_match
then
'equals'
else
'matches'
for
val
in
value
s
for
val
in
term
s
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
rule
.
options
...
...
h/static/scripts/services.coffee
View file @
778b1793
...
...
@@ -747,7 +747,7 @@ class ViewFilter
_anyMatches
:
(
filter
,
value
,
match
)
->
matchresult
=
[]
for
term
in
filter
.
terms
if
value
instanceof
Array
if
angular
.
isArray
value
matchresult
.
push
match
value
,
term
else
matchresult
.
push
match
term
,
value
...
...
@@ -758,7 +758,7 @@ class ViewFilter
return
false
if
autofalsefn
?
and
autofalsefn
annotation
value
=
checker
.
value
annotation
if
value
instanceof
Array
if
angular
.
isArray
value
if
filter
.
lowercase
then
value
=
value
.
map
(
e
)
->
e
.
toLowerCase
()
return
@
_arrayMatches
filter
,
value
,
checker
.
match
else
...
...
@@ -815,7 +815,6 @@ class ViewFilter
if
limit
and
results
.
length
>=
limit
then
break
for
category
,
filter
of
filters
continue
if
category
is
'timestamp'
break
unless
matches
terms
=
filter
.
terms
# No condition for this category
...
...
@@ -835,7 +834,7 @@ class ViewFilter
continue
if
conf
.
autofalse
?
and
conf
.
autofalse
annotation
value
=
conf
.
value
annotation
if
value
instanceof
Array
if
angular
.
isArray
value
if
filter
.
lowercase
value
=
value
.
map
(
e
)
->
e
.
toLowerCase
()
else
...
...
h/static/scripts/streamsearch.coffee
View file @
778b1793
...
...
@@ -18,11 +18,11 @@ SEARCH_VALUES =
class
StreamSearch
this
.
inject
=
[
'$location'
,
'$scope'
,
'$rootScope'
,
'queryparser'
,
'session'
,
'streamfilter'
'queryparser'
,
'session'
,
's
earchfilter'
,
's
treamfilter'
]
constructor
:
(
$location
,
$scope
,
$rootScope
,
queryparser
,
session
,
streamfilter
queryparser
,
session
,
s
earchfilter
,
s
treamfilter
)
->
# Initialize the base filter
streamfilter
...
...
@@ -31,7 +31,8 @@ class StreamSearch
.
setPastDataHits
(
50
)
# Apply query clauses
queryparser
.
populateFilter
streamfilter
,
$location
.
search
()
query
=
searchfilter
.
generateFacetedFilter
$location
.
search
().
query
queryparser
.
populateFilter
streamfilter
,
query
$scope
.
updater
?
.
then
(
sock
)
->
filter
=
streamfilter
.
getFilter
()
...
...
@@ -44,11 +45,9 @@ class StreamSearch
$scope
.
search
.
query
=
$location
.
search
()
$scope
.
search
.
show
=
not
angular
.
equals
(
$location
.
search
(),
{})
$scope
.
search
.
update
=
(
searchCollection
)
->
# Update the query parameters
query
=
queryparser
.
parseModels
searchCollection
.
models
unless
angular
.
equals
$location
.
search
(),
query
$location
.
search
query
$scope
.
search
.
update
=
(
query
)
->
unless
angular
.
equals
$location
.
search
(
query
),
query
$location
.
search
{
query
:
query
}
$scope
.
search
.
clear
=
->
$location
.
search
({})
...
...
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