I'd like the ability to do the following for certain fields in my documents:
Partial match (contains) searches
Prefix searches for autocomplete
Regular searches (for a default app-wide search box)
All while being able to sort against the fields. I read about multi-types
and did some Googling and came up with a settings object like this:
settings": {
"analysis": {
"analyzer": {
"str_filtered_search_analyzer": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
},
"str_prefix_analyzer": {
"tokenizer": "keyword",
"filter": [
"lowercase",
"prefix"
]
},
"str_substring_analyzer": {
"tokenizer": "keyword",
"filter": [
"lowercase",
"substring"
]
}
},
"filter": {
"prefix": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 24,
"side": "front"
},
"substring": {
"type": "nGram",
"min_gram": 2,
"max_gram": 24
}
}
}
}
And a mapping object like this (only includes 1 field for brevity):
"mappings": {
"group": {
"properties": {
"name": {
"type": "multi_field",
"fields": {
"name": {
"type": "string"
},
"prefix": {
"type": "string",
"index_analyzer": "str_prefix_analyzer",
"search_analyzer": "str_filtered_search_analyzer"
},
"substring": {
"type": "string",
"index_analyzer": "str_substring_analyzer",
"search_analyzer": "str_filtered_search_analyzer"
},
"sortable": {
"type": "string",
"index_analyzer": "str_filtered_search_analyzer"
}
}
}
}
},
}
Does this look right or is there a simpler scheme? I'm a little worried I'm
overdoing it.
Thanks,
Troy
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.