Created
December 19, 2012 14:49
-
-
Save martijnvg/4337178 to your computer and use it in GitHub Desktop.
Creating your own all field 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?pretty' | |
curl -XPUT 'localhost:9200/test?pretty' -d '{ | |
"mappings" : { | |
"test" : { | |
"properties" : { | |
"name" : { | |
"type" : "multi_field", | |
"path" : "just_name", | |
"fields" : { | |
"name" : {"type" : "string"}, | |
"my_all" : {"type" : "string", "index_name" : "my_all", "position_offset_gap" : 100} | |
} | |
}, | |
"description" : { | |
"type" : "multi_field", | |
"path" : "just_name", | |
"fields" : { | |
"description" : { "type" : "string" }, | |
"my_all" : { "type" : "string", "index_name" : "my_all", "position_offset_gap" : 100} | |
} | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT 'localhost:9200/test/test/1?refresh&pretty' -d '{ | |
"name" : "important name", | |
"description" : "description describing important name" | |
}' | |
# Is match | |
curl -XGET 'localhost:9200/test/_search?pretty' -d '{ | |
"query" : { | |
"match" : { | |
"my_all" : { | |
"query" : "important name", | |
"type" : "phrase" | |
} | |
} | |
} | |
}' | |
# Isn't a match | |
curl -XGET 'localhost:9200/test/_search?pretty' -d '{ | |
"query" : { | |
"match" : { | |
"my_all" : { | |
"query" : "name description", | |
"type" : "phrase" | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment