Can a special character be used in an object _type?


#1

I am just getting ready to start a new application. One of the objects is going to be based on a distribution list name that will come from the front end . Could I use this distribution list name as a _type without removing the "#" from the start of it?

Example
"theUser"{
"_type":"#distribution_1"
{
"stuff":"String"
}
"_type":"#distribution_2"
{
"stuff":"String"
}
}


(Ryan Ernst) #2

No, elasticsearch will reject type names with certain special characters (and # is one of those). Also note that types are going away: https://github.com/elastic/elasticsearch/issues/15613


(Ryan Ernst) #3

But you can put the value into your own field which you can use as a filter. That is actually what the recommended replacement for types if you really need them.


#4

rjernst - is there any performance value in beginning to just create new indices where I would typically make a new _type? I was considering what you brought up, and was going to just change "_type" to and new field called "type". Just want to make sure this is modeled correctly for upcoming releases.

Thanks for your time.


(Ryan Ernst) #5

Changing your application to use it's own type will work better with upcoming releases. However, as I mentioned, think about whether you really need multiple types within the same index, or could use separate indexes.


#6

Yes, thank you rjernst. I have already reworked the data structure for this application to only have 1 type per index. I just want to make sure that it will be "sitting pretty" for the forseable future of updates, It seems strange to me to have some many indicies, versus sorting data "relationships" by _type. No big deal really though, thanks for mentioning it to me.


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.