# Overkill with multi-type fields?

**URL:** <https://discuss.elastic.co/t/overkill-with-multi-type-fields/10974>\
**Category:** Elasticsearch\
**Created:** [March 2, 2013, 11:47am UTC](https://discuss.elastic.co/t/overkill-with-multi-type-fields/10974 "2013-03-02T11:47:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![troy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/troy/32/2547_2.png) [@troy](https://discuss.elastic.co/u/troy)\
**Post date:** [March 2, 2013, 11:47am UTC](https://discuss.elastic.co/t/overkill-with-multi-type-fields/10974/1 "2013-03-02T11:47:44Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:48am UTC](https://discuss.elastic.co/t/overkill-with-multi-type-fields/10974/2 "2017-07-06T02:48:44Z")

</div>


