Last active
August 29, 2015 14:03
-
-
Save geordee/6b5093dded71964cc868 to your computer and use it in GitHub Desktop.
Elasticsearch nGram Analyzer
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 'http://localhost:9200/alien' | |
curl -XPUT "http://localhost:9200/alien" -d' | |
{ | |
"settings": { | |
"analysis": { | |
"filter": { | |
"index_ngram_filter": { | |
"type": "edgeNGram", | |
"min_gram": 2, | |
"max_gram": 20, | |
"token_chars": [ | |
"letter", | |
"digit", | |
"punctuation", | |
"symbol" | |
] | |
} | |
}, | |
"analyzer": { | |
"index_ngram_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ | |
"lowercase", | |
"asciifolding", | |
"index_ngram_filter" | |
] | |
}, | |
"search_ngram_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ | |
"lowercase", | |
"asciifolding" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"creatures": { | |
"properties": { | |
"name": { | |
"type": "string", | |
"index_analyzer": "index_ngram_analyzer", | |
"search_analyzer": "search_ngram_analyzer" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/1' -d '{"name" : "Doughnut People"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/2' -d '{"name" : "Dolphin"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/3' -d '{"name" : "Magrathean"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/4' -d '{"name" : "Markovian"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/5' -d '{"name" : "Martian"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/6' -d '{"name" : "Martian Dog"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/7' -d '{"name" : "Maw"}' | |
curl -XPUT 'http://localhost:9200/alien/creatures/8' -d '{"name" : "Mawkaw Magkong"}' | |
curl -XPOST "http://localhost:9200/alien/_search" -d' | |
{ | |
"size": 10, | |
"query": { | |
"match": { | |
"name": { | |
"query": "martian", | |
"operator": "and" | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/alien/_search" -d' | |
{ | |
"size": 10, | |
"query": { | |
"match": { | |
"name": { | |
"query": "mar do" | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/alien/_search" -d' | |
{ | |
"size": 10, | |
"query": { | |
"match": { | |
"name": { | |
"query": "mar do", | |
"operator": "and" | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment