Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
b127daba
Commit
b127daba
authored
8 years ago
by
Megan Henning
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #339 from scitran/search-all-data
Allow user to limit search results
parents
95df596e
74089e5c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/handlers/searchhandler.py
+2
-1
2 additions, 1 deletion
api/handlers/searchhandler.py
api/search/queryprocessor.py
+10
-4
10 additions, 4 deletions
api/search/queryprocessor.py
with
12 additions
and
5 deletions
api/handlers/searchhandler.py
+
2
−
1
View file @
b127daba
...
...
@@ -73,11 +73,12 @@ class SearchHandler(base.RequestHandler):
queries
=
self
.
request
.
json_body
path
=
queries
.
pop
(
'
path
'
)
min_score
=
self
.
get_param
(
'
min_score
'
,
0.5
)
all_data
=
self
.
is_true
(
'
all_data
'
)
# if the path starts with collections force the targets to exists within a collection
if
path
.
startswith
(
'
collections
'
):
queries
[
'
collections
'
]
=
queries
.
get
(
'
collections
'
,
{
"
match_all
"
:
{}})
target_paths
=
pathparser
.
PathParser
(
path
).
paths
search
=
queryprocessor
.
PreparedSearch
(
target_paths
,
queries
)
search
=
queryprocessor
.
PreparedSearch
(
target_paths
,
queries
,
all_data
,
self
.
uid
)
return
search
.
process_search
()
...
...
This diff is collapsed.
Click to expand it.
api/search/queryprocessor.py
+
10
−
4
View file @
b127daba
...
...
@@ -26,21 +26,27 @@ querygraph = {
'
children
'
:
[
'
acquisitions
'
]
}
}
_min_score
=
1
class
SearchContainer
(
object
):
def
__init__
(
self
,
cont_name
,
query
,
targets
):
def
__init__
(
self
,
cont_name
,
query
,
targets
,
all_data
=
False
,
user
=
None
):
self
.
cont_name
=
cont_name
self
.
query
=
query
self
.
is_target
=
False
self
.
child_targets
=
set
()
self
.
results
=
None
self
.
all_data
=
all_data
self
.
user
=
user
for
t
in
targets
:
if
t
==
cont_name
:
self
.
is_target
=
True
else
:
self
.
child_targets
.
add
(
t
)
self
.
results
=
None
if
not
all_data
and
user
and
cont_name
==
'
projects
'
:
self
.
query
=
add_filter
(
self
.
query
,
'
permissions._id
'
,
user
)
def
get_results
(
self
):
if
self
.
query
is
None
:
...
...
@@ -141,7 +147,7 @@ class PreparedSearch(object):
containers
=
[
'
groups
'
,
'
projects
'
,
'
sessions
'
,
'
collections
'
,
'
acquisitions
'
]
def
__init__
(
self
,
target_paths
,
queries
):
def
__init__
(
self
,
target_paths
,
queries
,
all_data
=
False
,
user
=
None
):
self
.
queries
=
queries
self
.
target_lists
=
{}
for
path
in
target_paths
:
...
...
@@ -151,7 +157,7 @@ class PreparedSearch(object):
for
cont_name
in
self
.
containers
:
query
=
self
.
queries
.
get
(
cont_name
)
targets
=
self
.
target_lists
.
get
(
cont_name
,
[])
self
.
search_containers
[
cont_name
]
=
SearchContainer
(
cont_name
,
query
,
targets
)
self
.
search_containers
[
cont_name
]
=
SearchContainer
(
cont_name
,
query
,
targets
,
all_data
,
user
)
def
_get_targets
(
self
,
path
):
path_parts
=
path
.
split
(
'
/
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment