From d9c977b22c7cc8682d21d63da573b52b858f5190 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 18 Sep 2019 17:13:09 -0400 Subject: [PATCH] prevent dynamic mapping; avoid large raw keyword values Signed-off-by: Bill Erickson --- .../src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm index d3cdf49e88..7afd378bb4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm @@ -95,8 +95,12 @@ my $BASE_PROPERTIES = { # Values from grouped fields are copied into the group field. # Here we make some assumptions about the general purpose of # each group. + # Note the ignore_above only affects the 'keyword' version of the + # field, the assumption being text that large would solely be + # searched via 'text' indexes. title => { type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase', fields => { text => {type => 'text'}, @@ -105,6 +109,7 @@ my $BASE_PROPERTIES = { }, author => { type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase', fields => { text => {type => 'text'}, @@ -113,6 +118,7 @@ my $BASE_PROPERTIES = { }, subject => { type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase', fields => { text => {type => 'text'}, @@ -121,6 +127,7 @@ my $BASE_PROPERTIES = { }, series => { type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase', fields => { text => {type => 'text'}, @@ -132,6 +139,7 @@ my $BASE_PROPERTIES = { # keyword field, but we index it just the same (sans lowercase) # for structural consistency with other group fields. type => 'keyword', + ignore_above => 256, fields => { text => {type => 'text'}, text_folded => {type => 'text', analyzer => 'folding'} @@ -140,6 +148,7 @@ my $BASE_PROPERTIES = { identifier => { # Avoid full-text indexing on identifier fields. type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase', }, @@ -149,7 +158,10 @@ my $BASE_PROPERTIES = { se => {type => 'text'}, su => {type => 'text'}, kw => {type => 'text'}, - id => {type => 'keyword'} + id => { + type => 'keyword', + ignore_above => 256 + } }; my %SHORT_GROUP_MAP = ( @@ -228,6 +240,7 @@ sub create_index { $def = { type => 'keyword', + ignore_above => 256, normalizer => 'custom_lowercase' }; } @@ -235,7 +248,10 @@ sub create_index { if ($field->facet_field eq 't' && $def->{fields}) { # Facet fields are used for aggregation which requires # an additional unaltered keyword field. - $def->{fields}->{facet} = {type => 'keyword'}; + $def->{fields}->{facet} = { + type => 'keyword', + ignore_above => 256 + }; } $logger->debug("ES adding field $field_name: ". @@ -276,7 +292,7 @@ sub create_index { $self->es->indices->put_mapping({ index => $INDEX_NAME, type => 'record', - body => {properties => {$field => $mappings->{$field}}} + body => {dynamic => 'false', properties => {$field => $mappings->{$field}}} }); }; -- 2.11.0