Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created January 28, 2014 17:55
Show Gist options
  • Save clintongormley/8672716 to your computer and use it in GitHub Desktop.
Save clintongormley/8672716 to your computer and use it in GitHub Desktop.
curl -XPUT "http://localhost:9200/test " -d'
{
"settings": {
"analysis": {
"analyzer": {
"prefix": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"edge"
]
},
"multi_end": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"multi_end"
]
}
},
"filter": {
"multi_end": {
"type": "pattern_capture",
"patterns": [
"^(.+?).$",
"^(.+?)..$",
"^(.+?)...$",
"^(.+?)...$"
]
},
"edge": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20,
"token_chars": [
"letter",
"digit"
]
}
}
}
},
"mappings": {
"foo": {
"properties": {
"title": {
"type": "multi_field",
"fields": {
"title": {
"type": "string"
},
"prefix": {
"type": "string",
"index_analyzer": "prefix",
"search_analyzer": "multi_end"
}
}
}
}
}
}
}'
curl -XPUT "http://localhost:9200/test/foo/1" -d'
{
"title": "The quick brown foxes jumped over the lazy dogs"
}'
curl -XPOST "http://localhost:9200/test/foo/_search" -d'
{
"query": {
"match_phrase": {
"title.prefix": {
"query": "quick brown fox jumps"
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment