Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created December 19, 2012 14:49
Show Gist options
  • Save martijnvg/4337178 to your computer and use it in GitHub Desktop.
Save martijnvg/4337178 to your computer and use it in GitHub Desktop.
Creating your own all field with multi-field.
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