How to work with a json array


(Aussie Pete2015) #1

Hi all,

Environment
Windows 7 64bit
Elasticsearch, kibana, Logstash (5.0.0)

I have been trying to work with an example of a json array in the Elastic documentation but being new I'm not able to load it.
Attach json example

Attached index

Error when attempting to load via kibana
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "unknown setting [index.lists.0.description] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
}
],
"type": "illegal_argument_exception",
"reason": "unknown setting [index.lists.0.description] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
},
"status": 400
}

So understanding that I'm fairly green with this, can anyone please provide me steps to correctly set this example up in elastic.

Cheers


(Guilherme Maranhao) #2

Hi,

Have you tried removing the index_name clause associated with the property "tags"?
I'm not sure if this property is defined in an index mapping context.

kind regards,

Guilherme


(Guilherme Maranhao) #3

If you remove it, you'll need to reindex your data.


(Aussie Pete2015) #4

Hi Guilherme

Tried and failed... doesn't like the list

I'm just not sure what I need to write to accommodate an array.
I've used the example for Shakespeare just fine but the array has me beat.

Cheers for the assistance.


(Guilherme Maranhao) #5

Have you followed the object reference? https://www.elastic.co/guide/en/elasticsearch/reference/5.0/object.html

According to the exception, it's something wrong with the description.type property. Just to test it, have you tried removing the types properties of the inner object. It doesn't seem to be the cause, but just to verify it.


(Aussie Pete2015) #6

Hi Guilherme

That link helped enormously
Here's what I did in kibana

PUT /tweets
{
"mappings": {
"tweet": {
"properties": {
"tweetid": { "type": "keyword" },
"message": { "type": "text" },
"tags": { "type": "text" },
"content": {
"properties": {
"name": { "type": "text" },
"msgbody": { "type": "text" }
}
}
}
}
}
}

DELETE /regmanagers
PUT /regmanagers
{
"mappings": {
"regmanagers": {
"properties": {
"region": { "type": "keyword" },
"country": { "type": "text" },
"manager": {
"properties": {
"age": { "type": "integer" },
"name": { "type": "text" }
}
}
}
}
}
}
}

This has worked as expected.
Man so happy I understand now.

Cheers


(Aussie Pete2015) #7

Hi again

Thought I'd provide an update on this
Created my index
PUT /test
{
"mappings": {
"tweet": {
"properties": {
"message": {"type": "text"},
"tags": {"type": "text"},
"content": {
"properties": {
"name": {"type": "text"},
"msgbody": {"type": "text"}
}
}
}
}
}
}
Then added content
JSON content
{"index":{"_index":"tweets", "_type":"content", "_id": "2"}}
{"message":"I've now added a second tweet...", "tags":"elasticsearch wow yahoo", "contents.name":"prog_list", "contents.msgbody":"programming list"}

d:\Apps\curl>curl -XPUT localhost:9200/_bulk --data-binary @tweets.json

Now I will be happy to close this request as I'm slowly getting the hang of what to do.

Cheers


(Guilherme Maranhao) #8

Cool! Happy to know you did it! So, the solution was just replacing "string" to "text"?


(Aussie Pete2015) #9

Hi Guilherme

Actually it was a bit more than that. I used mappings in before the attribute and yes text seems to have resolved the other issues.
The link you provided was crucial to this resolution so thanks, greatly appreciate the tip.

Cheers


(system) #10

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