Skip to content

Instantly share code, notes, and snippets.

@runarmyklebust
Created March 23, 2012 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runarmyklebust/2171055 to your computer and use it in GitHub Desktop.
Save runarmyklebust/2171055 to your computer and use it in GitHub Desktop.
Elasticsearch setting all-field to analyzer keyword
Data:
{
..
..
"data_textfield" : "This is a text with whitespaces",
..
}
Query:
query: {
"from" : 0,
"size" : 200,
"query" : {
"wildcard" : {
"_all" : {
"wildcard" : "*text with*"
}
}
}
}
executed with 0 hits of total 0
Mapping:
{
"content":{
"_all":{
"enabled":true,
"index":"analyzed",
"analyzer":"keyword"
},
"_source":{
"enabled":false
},
"date_detection":false,
"numeric_detection":false,
"properties":{
"title":{
"type":"multi_field",
"fields":{
"title":{
"include_in_all":false,
"type":"string",
"index":"not_analyzed",
"store":"yes"
},
"_tokenized":{
"include_in_all":false,
"type":"string",
"index":"analyzed",
"store":"yes"
}
}
},
"dynamic_templates":[
{
"template_userdata":{
"include_in_all":true,
"match":"data_*",
"unmatch":"*_numeric",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed",
"store":"yes",
"include_in_all":true
},
"_tokenized":{
"type":"string",
"index":"analyzed",
"store":"yes",
"include_in_all":true
}
}
}
}
},
{
"template_orderby":{
"match":"orderby_*",
"unmatch":"*_numeric",
"mapping":{
"include_in_all":false,
"type":"string",
"index":"not_analyzed",
"store":"yes"
}
}
},
{
"template_numerics":{
"unmatch":"data_*",
"match":"*_numeric",
"mapping":{
"include_in_all":false,
"type":"double",
"store":"yes"
}
}
},
{
"template_userdata_numeric":{
"include_in_all":false,
"match":"*_numeric",
"mapping":{
"include_in_all":true,
"type":"double",
"store":"yes"
}
}
},
{
"template_general":{
"match":"*",
"mapping":{
"include_in_all":false,
"type":"string",
"store":"yes",
"index":"not_analyzed"
}
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment