Re: Mapping Arrays - Weird Question


(Adrien Grand) #1

Hi,

There is no need for a particular type for arrays[1]. Elasticsearch
automatically detects arrays, so instead of declaring a field as an array,
you need to declare what it contains. For example, assuming that
variablesUsed is an array of strings, you could define it as

"variablesUsed" : {"type" : "string", "store" : true, "index" : "analyzed"}

[1]
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-array-type.html

On Thu, Apr 10, 2014 at 2:52 PM, roblangenfeld roblangenfeld@gmail.comwrote:

So I'm working on the JSON mapping for several of our documents and one of
the fields happens to be a string array.

I looked at the documentation for how it's supposed to be done and it left
me confused. Could someone clarify it for me?

Here is essentially what I want to happen (part of my mapping):

"properties" :{
...
"variableId" : {"type" : "string", "store" : true, "index" :
"not_analyzed"},
"variableDisplayName" : {"type" : "string", "store" : true, "index" :
"analyzed"},
"variablesUsed" : {"type" : "array", "store" : true, "index" : "analyzed"},
"encryptedStatus" : {"type" : "boolean", "store" : true, "index" :
"not_analyzed"},
...
}

The third line being the string array. I know the syntax is wrong but that
is essentially what i want to accomplish. So with that being said would
this
be how I map it?:
"properties" :{
...
"variableId" : {"type" : "string", "store" : true, "index" :
"not_analyzed"},
"variableDisplayName" : {"type" : "string", "store" : true, "index" :
"analyzed"},
"variablesUsed" : {"type" : "array", "store" : true, "index" : "analyzed"},
"lists" : {
"properties" : {
"variablesUsed" : {"type" : "string", "store" : true,
"index" : "analyzed"}]
}
},
"encryptedStatus" : {"type" : "boolean", "store" : true, "index" :
"not_analyzed"},
...
}

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Mapping-Arrays-Weird-Question-tp4053902.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1397134368768-4053902.post%40n3.nabble.com
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4_D9m0cUtVaPG3dHsRXfa%2BnedSH%3DTiWuHCCoLk5iLopQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2