Skip to content

Commit

Permalink
mappings: add ngram analyzer
Browse files Browse the repository at this point in the history
* Allows partial matches on search
* closes CERNDocumentServer/cds-rdm#114
  • Loading branch information
jrcastro2 authored and carlinmack committed Jul 17, 2024
1 parent 6754cbf commit 20bbd8e
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
{
"settings": {
"index": {
"max_ngram_diff": 2
},
"analysis": {
"analyzer": {
"ngram_3_to_5_analyzer": {
"type": "custom",
"tokenizer": "ngram_tokenizer_3_to_5",
"filter": ["lowercase"]
}
},
"tokenizer": {
"ngram_tokenizer_3_to_5": {
"type": "ngram",
"min_gram": 3,
"max_gram": 5
}
}
}
},
"mappings": {
"dynamic": "strict",
"dynamic_templates": [
Expand Down Expand Up @@ -75,10 +96,22 @@
"type": "boolean"
},
"username": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email_hidden": {
"type": "keyword"
Expand Down Expand Up @@ -110,7 +143,8 @@
"profile": {
"properties": {
"full_name": {
"type": "text"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer"
},
"affiliations": {
"type": "text",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
{
"settings": {
"index": {
"max_ngram_diff": 2
},
"analysis": {
"analyzer": {
"ngram_3_to_5_analyzer": {
"type": "custom",
"tokenizer": "ngram_tokenizer_3_to_5",
"filter": ["lowercase"]
}
},
"tokenizer": {
"ngram_tokenizer_3_to_5": {
"type": "ngram",
"min_gram": 3,
"max_gram": 5
}
}
}
},
"mappings": {
"dynamic": "strict",
"dynamic_templates": [
Expand Down Expand Up @@ -75,10 +96,22 @@
"type": "boolean"
},
"username": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email_hidden": {
"type": "keyword"
Expand Down Expand Up @@ -110,7 +143,8 @@
"profile": {
"properties": {
"full_name": {
"type": "text"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer"
},
"affiliations": {
"type": "text",
Expand Down
40 changes: 37 additions & 3 deletions invenio_users_resources/records/mappings/v7/users/user-v2.0.0.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
{
"settings": {
"index": {
"max_ngram_diff": 2
},
"analysis": {
"analyzer": {
"ngram_3_to_5_analyzer": {
"type": "custom",
"tokenizer": "ngram_tokenizer_3_to_5",
"filter": ["lowercase"]
}
},
"tokenizer": {
"ngram_tokenizer_3_to_5": {
"type": "ngram",
"min_gram": 3,
"max_gram": 5
}
}
}
},
"mappings": {
"dynamic": "strict",
"dynamic_templates": [
Expand Down Expand Up @@ -75,10 +96,22 @@
"type": "boolean"
},
"username": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email": {
"type": "keyword"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"email_hidden": {
"type": "keyword"
Expand Down Expand Up @@ -110,7 +143,8 @@
"profile": {
"properties": {
"full_name": {
"type": "text"
"type": "text",
"analyzer": "ngram_3_to_5_analyzer"
},
"affiliations": {
"type": "text",
Expand Down

0 comments on commit 20bbd8e

Please sign in to comment.