Created
September 14, 2012 19:17
-
-
Save jmitchener/3724082 to your computer and use it in GitHub Desktop.
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
echo "--- DELETING OLD INDEX ---" | |
curl -XDELETE 'http://localhost:9200/ngramtest?pretty' | |
echo "--- CREATING INDEX ---" | |
curl -XPUT 'http://127.0.0.1:9200/ngramtest/?pretty=1' -d '{ | |
"mappings" : { | |
"footype" : { | |
"properties" : { | |
"label" : { | |
"type": "string", | |
"index_analyzer": "left_edgengram", | |
"search_analyzer": "standard" | |
}, | |
"description": { | |
"type": "string", | |
"index_analyzer": "left_edgengram", | |
"search_analyzer": "standard" | |
} | |
} | |
} | |
}, | |
"settings" : { | |
"analysis" : { | |
"analyzer" : { | |
"left_edgengram" : { | |
"filter" : [ "standard", "lowercase", "stop" ], | |
"type" : "custom", | |
"tokenizer" : "left_edge_tokenizer" | |
} | |
}, | |
"tokenizer" : { | |
"left_edge_tokenizer" : { | |
"side" : "front", | |
"max_gram" : 200, | |
"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!" | |
}' | |
curl -XPOST 'http://localhost:9200/ngramtest/footype?pretty=1' -d '{ | |
"label": "Alaska match1", | |
"description": "This better not be the only match!" | |
}' | |
curl -XPOST 'http://localhost:9200/ngramtest/footype?pretty=1' -d '{ | |
"label": "Another match here?", | |
"description": "This should match on Alaska" | |
}' | |
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