Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@focampo
Created January 24, 2012 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save focampo/1671402 to your computer and use it in GitHub Desktop.
Save focampo/1671402 to your computer and use it in GitHub Desktop.
ES - Adding new custom analyzer
#Creating index with a custom analyzer
curl -XPUT "http://localhost:9200/myindex/" -d '{
"settings" : {
"analysis": {
"analyzer": {
"my_analyzer": {
"type": "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "asciifolding"]
}
}
}
}
}'
#Testing 'my_analyzer' analyzer
curl -XGET "http://localhost:9200/myindex/_analyze?format=text&analyzer=my_analyzer" -d 'Analyze this please'
#Closing index
curl -XPOST 'http://localhost:9200/myindex/_close'
#Adding new analyzer
curl -XPUT http://localhost:9200/myindex/_settings -d '{
"analysis": {
"analyzer": {
"my_other_analyzer": {
"type": "custom",
"tokenizer" : "standard",
"filter" : ["lowercase", "word_delimiter"]
}
}
}
}'
#Reopening index
curl -XPOST http://localhost:9200/myindex/_open
#Testing 'my_other_analyzer' analyzer
curl -XGET "http://localhost:9200/myindex/_analyze?format=text&analyzer=my_other_analyzer" -d 'AnalyzeThisPlease'
@kimchy
Copy link

kimchy commented Jan 24, 2012

The update settings should be this:

curl -XPUT localhost:9200/myindex/_settings -d '{
    "analysis": {
        "analyzer": {
            "my_other_analyzer": {
                "type": "custom",
                "tokenizer" : "standard",
                "filter" : ["lowercase", "word_delimiter"]
            }
        }
    }
}'

@focampo
Copy link
Author

focampo commented Jan 24, 2012

Thanks Kimchy. Fixed and working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment