Can analyzer setting sources loaded from external location using java?


(Sam-4) #1

Hi

I'm using following sources setting for analyzer:

{
"index" : {
"analysis" : {
"analyzer" : {
"customindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
},
"customsearchanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
}
},
"filter" : {
"mystopword": {
"type" : "stop",
"stopwords_path" :"F:/resources/stopwordeng.txt" ,
"ignore_case":true
}
}
}
}
}

I have read following document : http://www.elasticsearch.org/guide/reference/setup/configuration.html
I want to put this setting into external json file and load this json
file when i index the document.can it is possible using java.

Thanks


(Karussell) #2

Use autocompletion of your IDE :wink: and choose one of:

client.admin().cluster().prepareUpdateSettings().setPersistentSettings(map);
client.admin().cluster().prepareUpdateSettings().setTransientSettings(map)
// or for index related settings
client.admin().indices().preparePutMapping("your_index_name").setSource(map);

Peter.

On 23 Jan., 05:55, sam mishra.sam...@gmail.com wrote:

Hi

I'm using following sources setting for analyzer:

{
"index" : {
"analysis" : {
"analyzer" : {
"customindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
},
"customsearchanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]}
},

"filter" : {
"mystopword": {
"type" : "stop",
"stopwords_path" :"F:/resources/stopwordeng.txt" ,
"ignore_case":true

}
}
}
}
}

I have read following document :http://www.elasticsearch.org/guide/reference/setup/configuration.html
I want to put this setting into external json file and load this json
file when i index the document.can it is possible using java.

Thanks


(Shay Banon) #3

You can use the create index API.

String indexSettings = // load the json from wherever you want
client.admin().indices().prepareCreate("index_name").setSettings(indexSettings).execute().actionGet();

On Mon, Jan 23, 2012 at 6:55 AM, sam mishra.sameek@gmail.com wrote:

Hi

I'm using following sources setting for analyzer:

{
"index" : {
"analysis" : {
"analyzer" : {
"customindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
},
"customsearchanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
}
},
"filter" : {
"mystopword": {
"type" : "stop",
"stopwords_path" :"F:/resources/stopwordeng.txt" ,
"ignore_case":true
}
}
}
}
}

I have read following document :
http://www.elasticsearch.org/guide/reference/setup/configuration.html
I want to put this setting into external json file and load this json
file when i index the document.can it is possible using java.

Thanks


(system) #4