Skip to content

Commit

Permalink
indexing: update mef persons mapping
Browse files Browse the repository at this point in the history
* Adds analyzer on biographical_information, preferred_name_for_person,
  authorized_access_point_representing_a_person and variant_name_for_person fields.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Jun 11, 2019
1 parent 280aa05 commit 3a71711
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,22 @@
"type": "keyword"
},
"biographical_information": {
"type": "text"
"type": "text",
"analyzer": "global_lowercase_asciifolding"
},
"preferred_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"variant_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"authorized_access_point_representing_a_person": {
"type": "text"
"type": "text",
"analyzer": "global_lowercase_asciifolding"
},
"pid": {
"type": "keyword"
Expand Down Expand Up @@ -111,15 +115,18 @@
"type": "keyword"
},
"biographical_information": {
"type": "text"
"type": "text",
"analyzer": "global_lowercase_asciifolding"
},
"preferred_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"variant_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"authorized_access_point_representing_a_person": {
"type": "text"
Expand Down Expand Up @@ -147,15 +154,18 @@
"type": "keyword"
},
"biographical_information": {
"type": "text"
"type": "text",
"analyzer": "global_lowercase_asciifolding"
},
"preferred_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"variant_name_for_person": {
"type": "text",
"copy_to": "autocomplete_name"
"copy_to": "autocomplete_name",
"analyzer": "global_lowercase_asciifolding"
},
"authorized_access_point_representing_a_person": {
"type": "text"
Expand All @@ -174,4 +184,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1253,4 +1253,4 @@
"transaction_location_pid": "loc1",
"transaction_user_pid": "ptrn2"
}
}
}
14 changes: 0 additions & 14 deletions tests/ui/mef_persons/test_mef_persons_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,3 @@ def test_mef_person_create(db, mef_person_data_tmp):
)
pers = MefPerson.get_record_by_pid('1')
assert pers.get('viaf_pid') == '1234'


def test_mef_person_es_mapping(es_clear, db, mef_person_data_tmp):
"""Test mef elasticsearch mapping."""
search = MefPersonsSearch()
mapping = get_mapping(search.Meta.index)
assert mapping
MefPerson.create(
mef_person_data_tmp,
dbcommit=True,
reindex=True,
delete_pid=True
)
assert mapping == get_mapping(search.Meta.index)
80 changes: 80 additions & 0 deletions tests/ui/mef_persons/test_mef_persons_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
#
# This file is part of RERO ILS.
# Copyright (C) 2017 RERO.
#
# RERO ILS is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# RERO ILS is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RERO ILS; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, RERO does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

"""Mef Persons Record tests."""

from utils import get_mapping

from rero_ils.modules.mef_persons.api import MefPerson, MefPersonsSearch


def test_mef_persons_search_mapping(
app, mef_person
):
"""Test Mef Persons search mapping."""
search = MefPersonsSearch()

c = search.query('query_string', query='ordonné prêtre').count()
assert c == 1

c = search.query('query_string', query='ordonne pretre').count()
assert c == 1

c = search.query(
'match',
**{'bnf.biographical_information': 'ordonné'}).\
count()
assert c == 1

c = search.query(
'match',
**{'bnf.biographical_information': 'ordonne'}).\
count()
assert c == 1

c = search.query(
'match',
**{'gnd.preferred_name_for_person': 'Arnoudt'}).\
count()
assert c == 1

c = search.query(
'match',
**{'gnd.variant_name_for_person': 'Arnoudt'}).\
count()
assert c == 1


def test_mef_person_es_mapping(es_clear, db, mef_person_data_tmp):
"""Test mef elasticsearch mapping."""
search = MefPersonsSearch()
mapping = get_mapping(search.Meta.index)
assert mapping
MefPerson.create(
mef_person_data_tmp,
dbcommit=True,
reindex=True,
delete_pid=True
)
assert mapping == get_mapping(search.Meta.index)

0 comments on commit 3a71711

Please sign in to comment.