peterk
(Peter Kühn)
June 8, 2016, 3:33pm
1
It seems to be impossible to query the mapping information of an explicitly defined index type.
Example:
type mapping in work_mapping.json:
... ----------------------------- begin example snipset ----------------------------
** "person" : {**
** "type" : "string",**
** "index_options" : "offsets"**
** },**
** "registrationStatus" : {**
** "type" : "string",**
** "index" : "no",**
"norms": {
** "enabled": false**
** }**
** },**
** "title" : {**
** "type" : "string",**
** "index_options" : "offsets"**
** },**
** "trigger" : {**
** "type" : "string",**
** "index" : "no",**
"norms": {
** "enabled": false**
** }**
... ----------------------------- end example snipset ----------------------------
define mapping type:
$ curl -XPUT 'http://localhost:9200/testindex/_mapping/test ' --data-binary @work_mapping.json
after adding some documents I want to query the type mapping
$ curl -XGET 'http://localhost:9200/testindex/_mapping/test?pretty'|more
... ----------------------------- begin example snipset ----------------------------
** "person" : {**
** "type" : "string"**
** },**
** "registrationStatus" : {**
** "type" : "string"**
** },**
** "title" : {**
** "type" : "string"**
** },**
** "trigger" : {**
** "type" : "string"**
** },**
... ----------------------------- end example snipset ----------------------------
So I'm missing essential information about field definitions. Is this just a flaw in ES?
Kind Regards
Peter
Do you get back any errors when you execute
curl -XPUT 'http://localhost:9200/testindex/_mapping/test'
If you do, your mapping is probably not getting applied and what you get is dynamically discovered mapping that is the result of you indexing the document.
It's hard to see from your example what you are actually sending as a mapping, could you edit your post using the following format?
```
your json
goes here
```
peterk
(Peter Kühn)
June 9, 2016, 7:15am
3
bash-4.2$ curl -XPUT 'http://localhost:9200/testindex '
{"acknowledged":true}bash-4.2$
bash-4.2$ curl -XPUT 'http://localhost:9200/testindex/_mapping/test ' --data-binary @work_mapping.json
{"acknowledged":true}bash-4.2$
another guess?
peterk
(Peter Kühn)
June 9, 2016, 7:33am
4
something must have happened - now it works!
curl -XGET 'http://localhost:9200/testindex/_mapping/test?pretty '
...
"person" : {
"type" : "string",
"index_options" : "offsets"
},
"registrationStatus" : {
"type" : "string",
"index" : "no",
"norms" : {
"enabled" : false
}
},
"title" : {
"type" : "string",
"index_options" : "offsets"
},
"trigger" : {
"type" : "string",
"index" : "no",
"norms" : {
"enabled" : false
}
},
...
that's exactly what I would have expected. So it seems to work. Sorry for that - my fault
Kind Regards
Peter
peterk
(Peter Kühn)
June 9, 2016, 12:41pm
5
now I know what's gone wrong
so once again:
delete work index
bash-4.2$ curl -XDELETE "http://localhost:9200/work "
{"acknowledged":true}
create new (empty) work index
bash-4.2$ curl -XPUT "http://localhost:9200/work "
{"acknowledged":true}
show target mapping for test type
bash-4.2$ cat work_test_mapping.json
{
"test" : {
"dynamic": "strict",
"_all" : {
"enabled" : false
},
"properties" : {
"dateAdded" : {
"type" : "string",
"index_options" : "docs",
"norms": {
"enabled": false
}
},
"dateOfChange" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis",
"index" : "no",
"norms": {
"enabled": false
}
},
"person" : {
"type" : "string",
"index_options" : "offsets"
},
"title" : {
"type" : "string",
"index_options" : "offsets"
},
"trigger" : {
"type" : "string",
"index" : "no",
"norms": {
"enabled": false
}
},
"updateId" : {
"type" : "string",
"index_options" : "docs",
"norms": {
"enabled": false
}
}
}
}
}
apply (strict) mapping
bash-4.2$ curl -XPUT 'http://localhost:9200/work/_mapping/test ' --data-binary @work_test_mapping.json
{"acknowledged":true}
show results - looks good...
bash-4.2$ curl -XGET 'http://localhost:9200/work/_mapping/test?pretty'|more
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1091 100 1091 0 0 139k 0 --:--:-- --:--:-- --:--:-- 152k
{
"work" : {
"mappings" : {
"test" : {
"dynamic" : "strict",
"_all" : {
"enabled" : false
},
"properties" : {
"dateAdded" : {
"type" : "string",
"norms" : {
"enabled" : false
},
"index_options" : "docs"
},
"dateOfChange" : {
"type" : "date",
"index" : "no",
"format" : "strict_date_optional_time||epoch_millis"
},
"person" : {
"type" : "string",
"index_options" : "offsets"
},
"title" : {
"type" : "string",
"index_options" : "offsets"
},
"trigger" : {
"type" : "string",
"index" : "no",
"norms" : {
"enabled" : false
}
},
"updateId" : {
"type" : "string",
"norms" : {
"enabled" : false
},
"index_options" : "docs"
}
}
}
}
}
}
now feed some data
bash-4.2$ cat /media/sf_common/work10.json |stream2es stdin --replace --target "http://localhost:9200/work/test "
2016-06-09T12:37:32.429+0000 INFO delete index http://localhost:9200/work
2016-06-09T12:37:33.041+0000 INFO 00:00,618 16,2d/s 4,8K/s (0,0mb) indexed 10 streamed 10 errors 0
2016-06-09T12:37:33.043+0000 INFO done
show mapping again
bash-4.2$ curl -XGET 'http://localhost:9200/work/_mapping/test?pretty'|more
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 634 100 634 0 0 59845 0 --:--:-- --:--:-- --:--:-- 63400
{
"work" : {
"mappings" : {
"test" : {
"_all" : {
"enabled" : false
},
"properties" : {
"dateAdded" : {
"type" : "string"
},
"dateOfChange" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
},
"person" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"trigger" : {
"type" : "string"
},
"updateId" : {
"type" : "string"
}
}
}
}
}
}
bash-4.2$
As what you may have suspected, it was the "--replace" option of es2stream what did the damage