Skip to content

Instantly share code, notes, and snippets.

@jprante
Created December 6, 2012 11:30
Show Gist options
  • Save jprante/4223832 to your computer and use it in GitHub Desktop.
Save jprante/4223832 to your computer and use it in GitHub Desktop.
Content with different languages
curl -XDELETE 'http://localhost:9200/test_cms'
curl -XPUT 'http://localhost:9200/test_cms'
curl -XPUT 'http://localhost:9200/test_cms/en/_mapping' -d '{
"document" : {
"properties": {
"name": { "type": "string" },
"content": {
"properties": {
"visible": { "type": "boolean" },
"data": { "type": "string", "analyzer": "english" }
}
}
}
}
}'
curl -XPUT 'http://localhost:9200/test_cms/es/_mapping' -d '{
"document" : {
"properties": {
"name": { "type": "string" },
"content": {
"properties": {
"visible": { "type": "boolean" },
"data": { "type": "string", "analyzer": "spanish" }
}
}
}
}
}'
curl -XPUT 'http://localhost:9200/test_cms/fr/_mapping' -d '{
"document" : {
"properties": {
"name": { "type": "string" },
"content": {
"properties": {
"visible": { "type": "boolean" },
"data": { "type": "string", "analyzer": "french" }
}
}
}
}
}'
curl -XPUT 'http://localhost:9200/test_cms/en/1' -d '{
"name": "Some Name",
"content":
{
"visible": true,
"data": "Some english content"
}
}'
curl -XPUT 'http://localhost:9200/test_cms/es/1' -d '{
"name": "Some Name",
"content":
{
"visible": true,
"data": "Some spanish content"
}
}'
curl -XPUT 'http://localhost:9200/test_cms/fr/1' -d '{
"name": "Some Name",
"content": {
"visible": false,
"data": "Some french content"
}
}'
curl -XPUT 'http://localhost:9200/test_cms/en/2' -d '{
"name": "Some Name",
"content":
{
"visible": true,
"data": "Some other english content"
}
}'
curl -XPUT 'http://localhost:9200/test_cms/es/2' -d '{
"name": "Some Name",
"content":
{
"visible": true,
"data": "Some other spanish content"
}
}'
curl -XPUT 'http://localhost:9200/test_cms/fr/2' -d '{
"name": "Some Name",
"content": {
"visible": true,
"data": "Some other french content"
}
}'
curl -XGET 'localhost:9200/_refresh'
# one result
curl -XGET 'http://localhost:9200/test_cms/en,fr/_search?pretty=true' -d '
{
"query": {
"bool" : {
"must" : [
{ "match" : { "data" : "other" }},
{ "term" : { "visible": true }}
]
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment