Alex Rivera | Logout

Define custom ElasticSearch Analyzer using Java API

Asked 2011-06-08T07:50:36.497
26

Is there a way to create an index and specify a custom analyzer using the Java API? It supports adding mappings at index creation, but I can't find a way to do something like this without sending the JSON via HTTP PUT:

curl -XPUT localhost:9200/twitter?pretty=true -d '{
"analysis": {
       "analyzer": {
            "steak" : {
                "type" : "custom", 
                "tokenizer" : "standard",
                "filter" : ["snowball", "standard", "lowercase"]
            }
        }
    }
}'

I can build such a query using JSONBuilder, but I can't find no place in the API where to run it, CreateIndexRequest doesn't have anything I can use and neither does client.admin().indices(), as far as I can see. What's the right way to do this?

Edit
Report

1 Answer

1

If you are on a test environnent you can also uses this project which will create your indexes based on Java annotations. https://github.com/tlrx/elasticsearch-test

answered 2012-07-04T10:17:08.267

Your Answer