Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
webservices
cern-search
cern-search-rest-api
Commits
05f8e6eb
Commit
05f8e6eb
authored
Jan 24, 2019
by
Pablo Panero
Browse files
indexer: add parameter extraction before indexing
parent
0d2d3ff1
Changes
3
Hide whitespace changes
Inline
Side-by-side
cern_search_rest_api/config.py
View file @
05f8e6eb
...
...
@@ -78,6 +78,7 @@ INDEXER_DEFAULT_INDEX = os.getenv('CERN_SEARCH_DEFAULT_INDEX', 'cernsearch-test-
SEARCH_MAPPINGS
=
[
os
.
getenv
(
'CERN_SEARCH_INSTANCE'
,
'cernsearch-test'
)]
SEARCH_USE_EGROUPS
=
ast
.
literal_eval
(
os
.
getenv
(
'CERN_SEARCH_USE_EGROUPS'
,
'True'
))
SEARCH_DOC_PIPELINES
=
ast
.
literal_eval
(
os
.
getenv
(
'CERN_SEARCH_DOC_PIPELINES'
,
'{}'
))
# Records REST configuration
# ===========================
...
...
cern_search_rest_api/modules/cernsearch/ext.py
View file @
05f8e6eb
...
...
@@ -7,7 +7,10 @@
# granted to it by virtue of its status as Intergovernmental Organization
# or submit itself to any jurisdiction.
from
cern_search_rest_api.modules.cernsearch.views
import
build_blueprint
,
build_health_blueprint
from
invenio_indexer.signals
import
before_record_index_arguments
from
cern_search_rest_api.modules.cernsearch.indexer
import
csas_indexer_receiver
from
cern_search_rest_api.modules.cernsearch.views
import
build_blueprint
class
CERNSearch
(
object
):
...
...
@@ -23,6 +26,7 @@ class CERNSearch(object):
self
.
init_config
(
app
)
blueprint
=
build_blueprint
(
app
)
app
.
register_blueprint
(
blueprint
)
before_record_index_arguments
.
connect
(
csas_indexer_receiver
,
sender
=
app
)
app
.
extensions
[
"cern-search"
]
=
self
def
init_config
(
self
,
app
):
...
...
cern_search_rest_api/modules/cernsearch/indexer.py
0 → 100644
View file @
05f8e6eb
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018, CERN
# This software is distributed under the terms of the GNU General Public
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".
# In applying this license, CERN does not waive the privileges and immunities
# granted to it by virtue of its status as Intergovernmental Organization
# or submit itself to any jurisdiction.
from
flask
import
current_app
def
csas_indexer_receiver
(
sender
,
json
=
None
,
record
=
None
,
index
=
None
,
doc_type
=
None
,
arguments
=
None
,
**
kwargs
):
pipeline_mapping
=
current_app
.
config
[
'SEARCH_DOC_PIPELINES'
]
if
pipeline_mapping
:
pipeline
=
pipeline_mapping
.
get
(
doc_type
,
None
)
if
pipeline
:
arguments
[
'pipeline'
]
=
pipeline
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