elasticsearch


Mapping in elasticsearch for multiple fields


I want to apply following template to all the fields.
Currently I am applying this mapping only for "name" field.
Lets say I have some more fields also exa : "resedential_address","work_address","birth_place","DOB" etc.
How can I do this in efficient way. I know I can repeat the same block for all the fields.
Or is there a way where in I can apply following template to all the "text" fields ?
{
"template": "*",
"settings": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "ngram",
"min_gram": 1,
"max_gram": 25
}
},
"analyzer": {
"case_insensitive": {
"tokenizer": "whitespace",
"filter": [
"ngram_filter","lowercase"
]
},
"search_analyzer":{
"type": "custom",
"tokenizer": "whitespace",
"filter": "lowercase"
}
}
}
},
"mappings": {
"my_type": {
"properties": {
"name": {
"type": "string",
"analyzer": "case_insensitive",
"search_analyzer": "search_analyzer"
}
}
}
}
}
Thanks in advance!
If you want to map all text fields with provided custom mapping then use dynamic templates feature as shown below:
{
"template": "*",
"settings": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "ngram",
"min_gram": 1,
"max_gram": 25
}
},
"analyzer": {
"case_insensitive": {
"tokenizer": "whitespace",
"filter": [
"ngram_filter","lowercase"
]
},
"search_analyzer":{
"type": "custom",
"tokenizer": "whitespace",
"filter": "lowercase"
}
}
}
},
"mappings": {
"my_type": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "string",
"analyzer": "case_insensitive",
"search_analyzer": "search_analyzer"
}
}
}
]
}
}
}
Above template will create the same custom mapping for all string fields like name, residential_address, work_address ...

Related Links

Elasticsearch: suggest users based on likes
Set every property type to not_analyzed for custom object
How to tell ElasticSearch to create nested fields
Elasticsearch minimum master nodes
How to create an Elasticsearch index without word-splitting?
Run a simple sql group by query in kibana 4
Clearing ttl from an object in elasticsearch
how can i search for values that have “-” dash in them with elastic search
Elasticsearch array of query strings
ElasticSearch Update Multi-field Mapping
Referencing to another index in elasticsearch
Elasticsearch : Need advice on architectural design of my cluster
What is pro/con of having big ES index or several small ES indexs on same data?
Elasticsearch get works half of the time
Scoring by term position in ElasticSearch?
Multi-word Term Vectors with Word nGrams?

Categories

HOME
google-chrome
artificial-intelligence
memory
generics
automapper
loopbackjs
ant
web2py
mosquitto
hyperledger
minecraft
phpseclib
tfs2010
fasm
getopenfilename
jquery-select2-4
reselect
maven-plugin
eclipse-emf
opentext
data-collection
fstar
sap-lumira
running-object-table
uilocalnotification
seafile-server
android-canvas
cups
xll
android-n
widestring
spring-restcontroller
data-uri
classnotfoundexception
nuclio
sonicmq
winston
mongodb-aggregation
portability
annotatorjs
msg
xmlbeans
dmarc
perforce-integrate
noclassdeffounderror
exists
mathnet
distributed-cache
verisign
polymerfire
jsr363
ioctl
servicestack-bsd
roxygen2
whitespace-language
android-audiomanager
string.format
encryption-symmetric
cakephp-2.2
lmax
distributed-r
nachos
oxygene
jms-serializer
typesafe-stack
assetic
spring-security-acl
sensormanager
illuminate-container
sfinae
kaazing
uipangesturerecognizer
will-paginate
photo-management
principles
levels

Resources

Encrypt Message