Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
elasticsearch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
elasticsearch
Commits
5021a39f390e
Commit
5021a39f390e
authored
8 years ago
by
Arthur Lutz
Browse files
Options
Downloads
Patches
Plain Diff
search for containers
parent
b2a9d053f347
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
views.py
+24
-6
24 additions, 6 deletions
views.py
with
24 additions
and
6 deletions
views.py
+
24
−
6
View file @
5021a39f
...
...
@@ -39,8 +39,11 @@
'
creation_date
'
:
DateHistogramFacet
(
field
=
'
creation_date
'
,
interval
=
'
month
'
),
}
def
__init__
(
self
,
query
=
None
,
filters
=
{},
doc_types
=
None
,
index
=
None
):
def
__init__
(
self
,
query
=
None
,
filters
=
{},
doc_types
=
None
,
index
=
None
,
parents_for
=
None
,
children_for
=
None
):
if
index
:
self
.
index
=
index
if
doc_types
:
self
.
doc_types
=
doc_types
...
...
@@ -43,8 +46,10 @@
if
index
:
self
.
index
=
index
if
doc_types
:
self
.
doc_types
=
doc_types
self
.
parents_for
=
parents_for
self
.
children_for
=
children_for
super
(
CWFacetedSearch
,
self
).
__init__
(
query
,
filters
)
def
query
(
self
,
search
,
query
):
if
query
:
...
...
@@ -47,8 +52,12 @@
super
(
CWFacetedSearch
,
self
).
__init__
(
query
,
filters
)
def
query
(
self
,
search
,
query
):
if
query
:
return
compose_search
(
search
,
query
=
query
,
fields
=
self
.
fields
)
return
compose_search
(
search
,
query
=
query
,
fields
=
self
.
fields
,
parents_for
=
self
.
parents_for
,
children_for
=
self
.
children_for
)
# return search.query('multi_match', fields=self.fields,
# query=query)
return
search
...
...
@@ -82,6 +91,7 @@
indexer
.
get_connection
()
facet_selections
=
{}
start
,
stop
=
0
,
10
parents_for
=
children_for
=
None
for
key
,
value
in
self
.
_cw
.
form
.
items
():
if
key
.
startswith
(
'
es_
'
):
facet_selections
[
key
.
replace
(
'
es_
'
,
''
)]
=
value
...
...
@@ -85,6 +95,10 @@
for
key
,
value
in
self
.
_cw
.
form
.
items
():
if
key
.
startswith
(
'
es_
'
):
facet_selections
[
key
.
replace
(
'
es_
'
,
''
)]
=
value
if
key
==
'
parents_for
'
:
parents_for
=
value
if
key
==
'
children_for
'
:
children_for
=
value
if
key
==
'
page
'
:
start
=
(
max
(
int
(
value
)
-
1
,
0
))
*
10
stop
=
start
+
10
...
...
@@ -88,8 +102,11 @@
if
key
==
'
page
'
:
start
=
(
max
(
int
(
value
)
-
1
,
0
))
*
10
stop
=
start
+
10
search
=
self
.
customize_search
(
query_string
,
facet_selections
,
start
,
stop
)
search
=
self
.
customize_search
(
query_string
,
facet_selections
,
start
,
stop
,
parents_for
=
parents_for
,
children_for
=
children_for
)
# force search to be executed on our index, otherwise FacetSearch
# uses '_all'
search
.
index
=
self
.
_cw
.
vreg
.
config
[
'
index-name
'
]
...
...
@@ -104,7 +121,7 @@
self
.
display_results
(
response
)
def
customize_search
(
self
,
query_string
,
facet_selections
,
start
=
0
,
stop
=
10
):
start
=
0
,
stop
=
10
,
**
kwargs
):
'''
This is where one can customize the search by modifying the
query string and facet selection in an inherited class.
...
...
@@ -119,7 +136,8 @@
return
CWFacetedSearch
(
query_string
,
facet_selections
,
index
=
self
.
_cw
.
vreg
.
config
.
get
(
'
index-name
'
),
doc_types
=
indexable
)[
start
:
stop
]
doc_types
=
indexable
,
**
kwargs
)[
start
:
stop
]
def
display_results
(
self
,
response
):
'''
...
...
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