Created
March 18, 2013 15:31
-
-
Save zwrss/5188008 to your computer and use it in GitHub Desktop.
Mappings for elasticsearch not nested stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo | |
curl -XDELETE 'http://localhost:9200/items' | |
echo | |
curl -XPUT 'localhost:9200/items' -d ' | |
{ | |
"mappings" : { | |
"Item" : { | |
"dynamic" : false, | |
"properties" : { | |
"id" : { "type" : "string", "index" : "not_analyzed" }, | |
"name" : { "type" : "string", "index" : "not_analyzed" }, | |
"price" : { "type" : "double", "index" : "not_analyzed" }, | |
"type" : { "type" : "string", "index" : "not_analyzed" }, | |
"characteristics" : { "type" : "string", "index" : "not_analyzed" } | |
} | |
} | |
} | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Sonz flatscreen", | |
"price" : 200.0, | |
"type" : "TV", | |
"characteristics" : [ | |
"warranty_3 years", | |
"screen size_32 in", | |
"display_LCD" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Sonz flatscreen", | |
"price" : 200.0, | |
"type" : "TV", | |
"characteristics" : [ | |
"warranty_2 years", | |
"screen size_32 in", | |
"display_Plasma" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Sonz bigbum", | |
"price" : 200.0, | |
"type" : "TV", | |
"characteristics" : [ | |
"warranty_3 years", | |
"screen size_32 in", | |
"display_CRT", | |
"speakers_5.1" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Shark plazmos", | |
"price" : 300.0, | |
"type" : "TV", | |
"characteristics" : [ | |
"warranty_2 years", | |
"screen size_54 in", | |
"display_Plasma" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Sonz player", | |
"price" : 150.0, | |
"type" : "DVD Player", | |
"characteristics" : [ | |
"warranty_3 years" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Shark player", | |
"price" : 200.0, | |
"type" : "DVD Player", | |
"characteristics" : [ | |
"warranty_3 years" | |
] | |
} | |
' | |
echo | |
curl -XPOST 'http://localhost:9200/items/Item' -d ' | |
{ | |
"id" : "id1", | |
"name" : "Sonz HiFi", | |
"price" : 200.0, | |
"type" : "HIFI", | |
"characteristics" : [ | |
"warranty_3 years", | |
"speakers_5.1" | |
] | |
} | |
' | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -X POST 'localhost:9200/items/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"match_all" : {} | |
}, | |
"filter" : { | |
"and" : [ | |
{ "term" : { "type" : "TV" } }, | |
{ "term" : { "characteristics" : "warranty_3 years" } }, | |
{ "term" : { "characteristics" : "screen size_32 in" } } | |
] | |
}, | |
"facets" : { | |
"screen size" : { | |
"terms" : { | |
"field" : "characteristics", | |
"regex" : "screen size_.*", | |
"regex_flags" : "DOTALL" | |
}, | |
"facet_filter" : { | |
"and" : [ | |
{ "term" : { "type" : "TV" } }, | |
{ "term" : { "characteristics" : "warranty_3 years" } } | |
] | |
} | |
}, | |
"warranty" : { | |
"terms" : { | |
"field" : "characteristics", | |
"regex" : "warranty_.*", | |
"regex_flags" : "DOTALL" | |
}, | |
"facet_filter" : { | |
"and" : [ | |
{ "term" : { "type" : "TV" } }, | |
{ "term" : { "characteristics" : "screen size_32 in" } } | |
] | |
} | |
}, | |
"type" : { | |
"terms" : { "field" : "type" }, | |
"facet_filter" : { | |
"and" : [ | |
{ "term" : { "characteristics" : "warranty_3 years" } }, | |
{ "term" : { "characteristics" : "screen size_32 in" } } | |
] | |
} | |
}, | |
"name" : { | |
"terms" : { "field" : "name" }, | |
"facet_filter" : { | |
"and" : [ | |
{ "term" : { "type" : "TV" } }, | |
{ "term" : { "characteristics" : "warranty_3 years" } }, | |
{ "term" : { "characteristics" : "screen size_32 in" } } | |
] | |
} | |
} | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment