Hi all,
I'm trying to achieve this sequence with the java API :
1 - create a node
------------------- NodeFactory
Node node = NodeBuilder.nodeBuilder() //
-
.local(true).data(true) //* -
.settings(ImmutableSettings.settingsBuilder() //* -
.loadFromClasspath("elasticsearch/elasticsearch.yml"))
//*
-
.node();*
------------------- elasticsearch.yml
path:
- data: target*
2 - obtain a client from the node
Client client = node.client();
3 - create an index
-
if
(client.admin().indices().prepareExists("my-index").execute().actionGet().exists())
{*
*
client.admin().indices().prepareDelete("my-index").execute().actionGet();*
-
}*
client.admin().indices().prepareCreate("my-index").execute().actionGet();*
4 - update the index settings+mappings
- // load my-index.json as string*
client.admin().indices().prepareUpdateSettings().setSettings(settings).setIndices("my-index").execute().actionGet();
*
-------------------- elasticsearch/settings/my-index.json
{
- "settings": {*
-
"index" : {* -
"analysis" : {* -
"analyzer" : {* -
"default" : {* -
"type" : "snowball",* -
"language" : "French",* -
"filter": ["asciifolding","lowercase"]* -
},* -
"sortable": {* -
"tokenizer": "keyword",* -
"filter": ["lowercase"]* -
}* -
}* -
}* -
}* - },*
- "mappings": {*
-
"job_posting" : {* -
"properties" : {* -
"id" : {* -
"type" : "long",* -
"index" : "not_analyzed"* -
},* -
"job" : {* -
"dynamic" : "true",* -
"properties" : {* -
"howToApply" : {* -
"dynamic" : "true",* -
"properties" : {* -
"reference" : {* -
"index" : "not_analyzed",* -
"type" : "string"* -
}* -
}* -
}* -
}* -
}* -
}* -
}* - }*
}
It appears that the sequence doesn't work for me because when I read the
index mapping before querying it's not the same as the one I put.
For example, at runtime, job.howToApply.reference is analysed while I
marked it as "not_analysed"
This leads to false search results because the default mapping doesn't suit
me.
Any hints on how I can update a mappings+settings configuration in java ?
--
Cordialement/Regards,
Louis GUEYE
linkedin http://fr.linkedin.com/in/louisgueye |
bloghttp://deepintojee.wordpress.com/|
twitter http://twitter.com/#!/lgueye