Skip to content

Commit

Permalink
demosite: plug-in search
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
  • Loading branch information
Leonardo Rossi committed Mar 22, 2016
1 parent 7234003 commit 561cc90
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 19 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ static:
volumes:
- /home/invenio/.virtualenvs/invenio3/var/invenio3-instance/static
- /home/invenio/.virtualenvs/invenio3/src/invenio-theme/invenio_theme/static
- /home/invenio/.virtualenvs/invenio3/src/invenio-search-ui/invenio_search_ui/static
user: invenio
7 changes: 3 additions & 4 deletions docs/installation/installation-detailed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,11 @@ taken from the ``invenio-records`` package:
:end-before: # sphinxdoc-populate-with-demo-records-end
:literal:

Let's register incremental numerical persistent identifiers for the uploaded
demo records:
Let's index all the uploaded records:

.. include:: ../../scripts/populate-instance.sh
:start-after: # sphinxdoc-register-pid-begin
:end-before: # sphinxdoc-register-pid-end
:start-after: # sphinxdoc-index-all-records-begin
:end-before: # sphinxdoc-index-all-records-end
:literal:

Start instance
Expand Down
3 changes: 3 additions & 0 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@
-e git+https://github.com/inveniosoftware/invenio-config.git#egg=invenio-config
-e git+https://github.com/inveniosoftware/invenio-db.git#egg=invenio-db[postgresql,versioning]
-e git+https://github.com/inveniosoftware/invenio-i18n.git#egg=invenio-i18n
-e git+https://github.com/inveniosoftware/invenio-indexer.git#egg=invenio-indexer
-e git+https://github.com/inveniosoftware/invenio-logging.git#egg=invenio-logging
-e git+https://github.com/inveniosoftware/invenio-mail.git#egg=invenio-mail
-e git+https://github.com/inveniosoftware/invenio-marc21.git#egg=invenio-marc21
-e git+https://github.com/inveniosoftware/invenio-pidstore.git#egg=invenio-pidstore
-e git+https://github.com/inveniosoftware/invenio-query-parser.git#egg=invenio-query-parser
-e git+https://github.com/inveniosoftware/invenio-records-rest.git#egg=invenio-records-rest
-e git+https://github.com/inveniosoftware/invenio-records-ui.git#egg=invenio-records-ui
-e git+https://github.com/inveniosoftware/invenio-records.git#egg=invenio-records
-e git+https://github.com/inveniosoftware/invenio-rest.git#egg=invenio-rest
-e git+https://github.com/inveniosoftware/invenio-search-ui.git#egg=invenio-search-ui
-e git+https://github.com/inveniosoftware/invenio-search.git#egg=invenio-search
-e git+https://github.com/inveniosoftware/invenio-theme.git#egg=invenio-theme
46 changes: 45 additions & 1 deletion scripts/create-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ inveniomanage instance create ${INVENIO_WEB_INSTANCE}

# sphinxdoc-install-instance-begin
cd ${INVENIO_WEB_INSTANCE}
python setup.py install
pip install -e .
pip install -r requirements-devel.txt
# sphinxdoc-install-instance-end

# sphinxdoc-customise-instance-begin
Expand All @@ -147,6 +148,49 @@ echo "CELERY_ACCEPT_CONTENT=['json', 'msgpack', 'yaml']" >> ../../var/${INVENIO_
echo "" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg
echo "# Elasticsearch" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg
echo "SEARCH_ELASTIC_HOSTS='${INVENIO_ELASTICSEARCH_HOST}'" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg
RECORDS_REST_CONF=`cat <<EOF
RECORDS_REST_ENDPOINTS = dict(
recid=dict(
pid_type='recid',
pid_minter='recid',
pid_fetcher='recid',
search_index='marc21',
search_type=None,
record_serializers={
'application/json': ('invenio_records_rest.serializers'
':json_v1_response'),
},
search_serializers={
'application/json': ('invenio_records_rest.serializers'
':json_v1_search'),
},
list_route='/records/',
item_route='/records/<pid_value>',
default_media_type='application/json',
max_result_window=10000,
),
)
EOF
`
echo "${RECORDS_REST_CONF}" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg
RECORDS_UI_CONF=`cat <<EOF
RECORDS_UI_ENDPOINTS = dict(
recid=dict(
pid_type='recid',
route='/records/<pid_value>',
template='invenio_marc21/detail.html',
),
)
EOF
`
echo "${RECORDS_UI_CONF}" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg
JSONSCHEMAS_CONF=`cat <<EOF
JSONSCHEMAS_ENDPOINT='/schema'
JSONSCHEMAS_HOST='http://${INVENIO_WEB_HOST}:5000'
EOF
`
echo "${JSONSCHEMAS_CONF}" >> ../../var/${INVENIO_WEB_INSTANCE}-instance/${INVENIO_WEB_INSTANCE}.cfg

# sphinxdoc-customise-instance-end

# sphinxdoc-run-npm-begin
Expand Down
27 changes: 14 additions & 13 deletions scripts/populate-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ demomarc21pathname=$(echo "from __future__ import print_function; \
import pkg_resources; \
print(pkg_resources.resource_filename('invenio_records', \
'data/marc21/bibliographic.xml'))" | python)

# convert demo records from MARC21 to JSON and load them
# using randomly generated UUIDs:
demouuids=$(dojson -i $demomarc21pathname -l marcxml do marc21 | \
${INVENIO_WEB_INSTANCE} records create)
# define the schema for the records
SCHEMA="http://${INVENIO_WEB_HOST}/schema/marc21/bibliographic/bd-v1.0.0.json"
# convert demo records from MARC21 to JSON and load them:
demouuids=$(dojson -i $demomarc21pathname -l marcxml do marc21 schema ${SCHEMA} | \
${INVENIO_WEB_INSTANCE} records create --pid-minter recid)
# sphinxdoc-populate-with-demo-records-end

# sphinxdoc-register-pid-begin
recid=1
for demouuid in $demouuids; do
${INVENIO_WEB_INSTANCE} pid create \
-t rec -i $demouuid -s REGISTERED recid $recid
let recid=recid+1
done
# sphinxdoc-register-pid-end
# sphinxdoc-index-all-records-begin
# indexing
${INVENIO_WEB_INSTANCE} index init
sleep 20
${INVENIO_WEB_INSTANCE} index queue init
${INVENIO_WEB_INSTANCE} index reindex --yes-i-know
${INVENIO_WEB_INSTANCE} index run
sleep 25
# sphinxdoc-index-all-records-end
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
]

install_requires = [
'invenio-base>=1.0.0a3,<1.1.0',
'invenio-base>=1.0.0a6,<1.1.0',
'invenio-celery>=1.0.0a2,<1.1.0',
'invenio-config>=1.0.0a1,<1.1.0',
'invenio-i18n>=1.0.0a1,<1.1.0',
Expand Down

0 comments on commit 561cc90

Please sign in to comment.