Last active
November 30, 2015 22:10
-
-
Save jprante/f53d09a091ab4a92176d to your computer and use it in GitHub Desktop.
Simple Elasticsearch example for multifield
This file contains hidden or 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
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" | |
} | |
} | |
} |
This file contains hidden or 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
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