Skip to content

Instantly share code, notes, and snippets.

@jmitchener
Created September 6, 2012 23:19
Show Gist options
  • Save jmitchener/3661207 to your computer and use it in GitHub Desktop.
Save jmitchener/3661207 to your computer and use it in GitHub Desktop.
Edge N-Gram Test
echo "--- DELETING OLD INDEX ---"
curl -XDELETE 'http://localhost:9200/ngramtest?pretty'
echo "--- CREATING INDEX ---"
# [Tue Jun 21 12:05:39 2011] Protocol: http, Server: 192.168.5.103:9200
curl -XPUT 'http://127.0.0.1:9200/ngramtest/?pretty=1' -d '
{
"mappings" : {
"footype" : {
"properties" : {
"label" : {
"type": "string",
"analyzer": "left_edgengram"
},
"description": {
"type": "string",
"analyzer": "left_edgengram"
}
}
}
},
"settings" : {
"analysis" : {
"analyzer" : {
"left_edgengram" : {
"filter" : [ "standard", "lowercase", "stop" ],
"type" : "custom",
"tokenizer" : "left_edge_tokenizer"
}
},
"tokenizer" : {
"left_edge_tokenizer" : {
"side" : "front",
"max_gram" : 50,
"type" : "edgeNGram"
}
}
}
}
}'
echo "--- INSERTING RECORDS ---"
curl -XPOST 'http://localhost:9200/ngramtest/footype?pretty=1' -d '
{
"label": "Whoa, where am I?!",
"description": "I did something in Alaska today!"
}'
curl -XPOST 'http://localhost:9200/ngramtest/footype?pretty=1' -d '
{
"label": "Some label here",
"description": "I did something in California today!"
}'
curl -XPOST 'http://localhost:9200/ngramtest/footype?pretty=1' -d '
{
"label": "Trip to oregon",
"description": "I did something in Oregon today!"
}'
echo "--- RUNNING QUERY ---"
curl -XGET 'http://localhost:9200/ngramtest/footype/_search?pretty' -d '
{
"query" : {
"query_string" : {
"query" : "alask"
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment