Last active
November 10, 2016 19:10
-
-
Save EdgeCaseBerg/8a69688f087f601a382951eab1910120 to your computer and use it in GitHub Desktop.
Example of how to use copy_to in a reg-ex individual word or full string search
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 example_copy | |
{ | |
"mappings": { | |
"example" : { | |
"properties": { | |
"original" : { | |
"type": "string", | |
"copy_to": "copied" | |
}, | |
"copied" : { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
} | |
POST /example_copy/example | |
{ | |
"original" : "hello there friend" | |
} | |
# See that the copied field doesn't show up in the _source | |
POST /example_copy/_search | |
# Gets 1 result | |
POST /example_copy/_search | |
{ | |
"query": { | |
"regexp" : { | |
"original" : { | |
"value" : "t.*" | |
} | |
} | |
} | |
} | |
# Gets 0 results | |
POST /example_copy/_search | |
{ | |
"query": { | |
"regexp" : { | |
"copied" : { | |
"value" : "t.*" | |
} | |
} | |
} | |
} | |
# Gets 1 result | |
POST /example_copy/_search | |
{ | |
"query": { | |
"regexp" : { | |
"copied" : { | |
"value" : "h.*" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment