json


Unable to load json mapping Elasticsearch


I'm trying to map a json structure on Elasticsearch but something seems to be wrong because when I launch the curl command from my Windows prompt nothing appends except the underscore pulsing.
I use this curl command:
curl -H "Content-Type: application/json" -XPUT http://localhost:9200/technogym -d "{\"mappings\":{\"id\":{\"type\":\"string\"},\"key\":{\"type\":\"string\"},\"value\":{\"type\":\"object\",\"properties\":{\"rev\":{\"type\":\"string\"}}},\"doc\":{\"type\":\"object\",\"properties\":{\"_id\":{\"type\":\"string\"},\"_rev\":{\"type\":\"string\"},\"userID\":{\"type\":\"string\"},\"conversation_id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\",\"properties\":{\"text\":{\"type\":\"string\"}}},\"output\":{\"type\":\"object\",\"properties\":{\"text\":{\"type\":\"string\"}}},\"node_visited\":{\"type\":\"string\"},\"intents\":{\"properties\":{\"intent\":{\"type\":\"string\"},\"confidence\":{\"type\":\"string\"}}},\"entities\":{\"type\":\"object\",\"properties\":{\"entity\":{\"type\":\"string\"},\"location\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"confidence\":{\"type\":\"string\"}}},\"timestamp\":{\"type\":\"date\"}}}}}"
Here my jsonwith mapping (just to make it more readable):
EDIT
{"mappings": {
"_default_": {
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"rev": {
"type": "string"
}
}
},
"doc": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"_rev": {
"type": "string"
},
"userID": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"input": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"output": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"node_visited": {
"type": "string"
},
"intents": {
"properties": {
"intent": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"entities": {
"type": "object",
"properties": {
"entity": {
"type": "string"
},
"location": {
"type": "string"
},
"value": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"timestamp": {
"type": "date"
}
}
}
}
}}}
I don't know why I can't upload this mapping.
Thanks for any help.
create an index
curl -XPUT localhost:9200/technogym
{"acknowledged":true}
Then apply your mapping to whatever type you want, eg. technogym_type
curl -X PUT localhost:9200/technogym/technogym_type/_mapping -d '{
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"rev": {
"type": "string"
}
}
},
"doc": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"_rev": {
"type": "string"
},
"userID": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"input": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"output": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"node_visited": {
"type": "string"
},
"intents": {
"properties": {
"intent": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"entities": {
"type": "object",
"properties": {
"entity": {
"type": "string"
},
"location": {
"type": "string"
},
"value": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"timestamp": {
"type": "date"
}
}
}
}
}'
{"acknowledged":true}
But if you dynamically want to create index and mappings, just fix your JSON document where it needs mappings (plural) and followed by the name of the type you want. (type equivalent to RDBMS table name)
curl -X PUT localhost:9200/technogym1 -d '
{
"mappings": {
"technogym_type1": {
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"rev": {
"type": "string"
}
}
},
"doc": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"_rev": {
"type": "string"
},
"userID": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"input": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"output": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"node_visited": {
"type": "string"
},
"intents": {
"properties": {
"intent": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"entities": {
"type": "object",
"properties": {
"entity": {
"type": "string"
},
"location": {
"type": "string"
},
"value": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"timestamp": {
"type": "date"
}
}
}
}
}
}
}'
{"acknowledged":true,"shards_acknowledged":true}
You need to change mapping to mappings.
{
"mappings": { ==> change this
"_default_": {
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"rev": {
"type": "string"
}
}
},
"doc": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"_rev": {
"type": "string"
},
"userID": {
"type": "string"
},
"conversation_id": {
"type": "string"
},
"input": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"output": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"node_visited": {
"type": "string"
},
"intents": {
"properties": {
"intent": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"entities": {
"type": "object",
"properties": {
"entity": {
"type": "string"
},
"location": {
"type": "string"
},
"value": {
"type": "string"
},
"confidence": {
"type": "string"
}
}
},
"timestamp": {
"type": "date"
}
}}}}}}

Related Links

Grails Enumeration to JSON
Accessing POST json in clojure
Gallerific and lightbox modal
How to Parse RSS Data with JSON
Facebook Graph API inbox messages with no comments array
extjs nested model
wikipedia API: parse a table as JSON?
give json data to jqGrid view once
How do I update one controller with data from another controller with a service in angular?
ExtJS Specify the existing date format for conversion
Binding viewmodel with knockoutjs mapping
Bug in twitteR and sentiment analysis code [closed]
What's wrong with this JSON object?
Using ModelCompanion's fromJSON method in Play application throws a NoSuchMethodException
How do I parse this JSON-string in Go?
Sencha store and model set up for use with Json

Categories

HOME
laravel-5
cntk
dynamics-crm
textwatcher
agile
wxwidgets
thunderbird-addon
h2
vlc
snap.svg
websphere-liberty
slim-3
hosts
data-analysis
zoho
sonarqube-msbuild-runner
source-maps
memsql
spring-test
shopping-cart
tampermonkey
osmdroid
dss
fetch-api
ggmap
solidworks
pitest
jackson-dataformat-csv
percentage
postgresql-9.2
stocks
pycparser
phpspreadsheet
superpowered
lego
office365connectors
agent
intellij-idea-2016
google-account
excel-interop
text-classification
tofixed
photography
selenium-firefoxdriver
rxvt
polar-coordinates
pdfkit
keycode
nsfetchedresultscontrolle
pdflib
packagemaker
uistackview
vst
slam-algorithm
zurb-foundation-apps
jackson-databind
com-interop
achievements
elastix
django-south
git-rebase
altbeacon
throughput
drf-nested-routers
plone-3.x
mirrorlink
app.xaml
anti-patterns
subresource-integrity
pyrocms
urn
consensus
named-ranges
scala-2.11
ibmsbt
grunt-contrib-concat
colt
ssms-addin
ifft
mimosa
document-database
layered
nimrod
installshield-2009
javascriptmvc
dynamic-binding
visual-studio-2003
localtime
surveyor-gem
mailcore
qt4.6
subtract
expression-evaluation
nintendo
objectbrowser
posting
task-management
boost-date-time
winverifytrust
web-statistics

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App