Skip to content

Instantly share code, notes, and snippets.

@jprante
Last active November 30, 2015 22:10
Show Gist options
  • Save jprante/f53d09a091ab4a92176d to your computer and use it in GitHub Desktop.
Save jprante/f53d09a091ab4a92176d to your computer and use it in GitHub Desktop.
Simple Elasticsearch example for multifield
PUT /test/
{
"mappings": {
"docs" : {
"properties": {
"foo" : {
"type" : "string",
"fields": {
"bar" : {
"type": "string",
"index" : "not_analyzed"
}
}
}
}
}
}
}
PUT /test/docs/1
{
"foo" : "Hello world"
}
POST /test/docs/_search
{
"query" : {
"match": {
"foo": "Hello"
}
}
}
POST /test/docs/_search
{
"query" : {
"match": {
"foo.bar": "Hello world"
}
}
}
PUT /test/
{
"mappings": {
"docs" : {
"properties": {
"foo" : {
"type" : "multi_field",
"fields": {
"foo" : {
"type": "string"
},
"bar" : {
"type": "string",
"index" : "not_analyzed"
}
}
}
}
}
}
}
PUT /test/docs/1
{
"foo" : "Hello world"
}
POST /test/docs/_search
{
"query" : {
"match": {
"foo": "Hello"
}
}
}
POST /test/docs/_search
{
"query" : {
"match": {
"foo.bar": "Hello world"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment