Created
October 22, 2013 11:54
-
-
Save jprante/7099277 to your computer and use it in GitHub Desktop.
Demonstration of facets with multi_field
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
curl -XDELETE 'localhost:9200/test' | |
curl -XPUT 'localhost:9200/test/' -d ' | |
{ | |
"mappings" : { | |
"_default_": { | |
"properties" : { | |
"tags" : { | |
"type" : "multi_field", | |
"fields" : { | |
"tags" : { "type" : "string" }, | |
"raw" : { "type" : "string", "index" : "not_analyzed" } | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
curl -XPUT 'localhost:9200/test/data/1' -d ' | |
{ | |
"tags" : [ "foo" ] | |
} | |
' | |
curl -XPUT 'localhost:9200/test/data/2' -d ' | |
{ | |
"tags" : [ "bar" ] | |
} | |
' | |
curl -XPUT 'localhost:9200/test/data/3' -d ' | |
{ | |
"tags" : [ "foo bar" ] | |
} | |
' | |
curl -XPUT 'localhost:9200/test/data/4' -d ' | |
{ | |
"tags" : [ "foo", "bar", "foo bar" ] | |
} | |
' | |
curl -XGET 'localhost:9200/test/_refresh' | |
curl -XGET 'localhost:9200/test/_search?pretty' -d ' | |
{ | |
"query" : { | |
"match": { | |
"tags": "foo" | |
} | |
} | |
}' | |
curl -XGET 'localhost:9200/test/_search?pretty' -d ' | |
{ | |
"query" : { | |
"match": { | |
"tags": "bar" | |
} | |
} | |
}' | |
curl -XGET 'localhost:9200/test/_search?pretty' -d ' | |
{ | |
"query" : { | |
"match": { | |
"tags": "bar" | |
} | |
}, | |
"facets" : { | |
"f1" : { | |
"terms" : { | |
"field" : "tags.raw" | |
} | |
} | |
} | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment