I think this is a very basic question but I keep going around the houses so any help pointing me in the right direction would be appreciated.
I have inherited a java application which builds and elastic search index using spring-data-elasticsearch (1.2.1.RELEASE at the moment). I have modified this quite successfully in various trivial ways but now I want to add a custom analyzer to use on one field (char mapping to remove /'s).
The index being built is essentially 1 index with various document types. It seems to be built pretty much out of the box. I'm fairly new to java and spring but and tracking down all the config and auto-wiring can still outfox me sometimes but as far as I can see the client config in the context XML file points directly to the spring code and doesn't add much except the custom index name and a location for the repository interfaces and code
<elasticsearch:node-client id="esClient" local="true" cluster-name="products"/>
<elasticsearch:repositories base-package="com.warehouse.es.repos"/>
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="esClient"/>
</bean>
The code then seems to use an out of the box client object
@Autowired
public void setClient(Client client) throws IOException {
this.client = client;
and then goes on to set various typemappings using mapping files along these lines
createTypeMapping(client, Constants.INDEX_NAME, INDEX_TYPE, "Products.mapping");
Apologies if some of this is either too brief (or too much waffle for this basic question) but I'm trying to work out / find an example of how and where to add my custom analyzer. I have documentation and examples to show me how to create some json to create the custom analyzer (e.g. https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-mapping-charfilter.html#analysis-mapping-charfilter and some previous stackoverflow q&s's)
but I'm struggling to understand where I add this in my java code creating the index.
Obviously the more help the better (!) but really at this stage I'm trying to get a grip of whether I could just add the analyzer to the yml file or whether I need to add some code to modify the client in some way ? or possibly even just add it to the individual type mappings.
Thanks.
curl
command) or if the index/types creation is handled by your Spring application. In the latter case, I think you can follow some code samples from this link on github. – Andrei StefanProducts.mapping
with that content that looks like a type mapping indeed. Any data that you have in your cluster, though, needs to be re-indexed if you change the type mapping by adding a new analyzer. – Andrei Stefan