4

I am using spring-data-elasticsearch 1.1.2. I am trying to use java annotation to specify that a field should not be analyzed.

I use the following annotation: @Field(index = FieldIndex.not_analyzed) private String category;

The generated mapping does not include "index":"not_analyzed" for this field:

    "properties" : {
      "category" : {
        "type" : "string"
      },
      ...

I am having no luck finding helpful documentation about how to do this but it looks like it should work.

Should it work? Where can i find more information? How best to debug?

Thank you.

update: problem also present with the latest 1.2.0 version.

2
  • Could you find a solution for this issue? I am facing exactly the same situation... Commented Sep 24, 2015 at 13:26
  • 1
    Yes. Turns out I had some misconceptions about spring data elasticsearch's ability to update existing mappings. This was solved by removing and recreating the index. Commented Nov 11, 2015 at 13:05

1 Answer 1

3

Similar question asked here: Spring Data Elasticsearch's @Field annotation not working

You have to explicitly put the mapping into the cluster on the application startup.

elasticsearchTemplate.putMapping(YourDocument.class);

Your node/cluster has no idea about the document you are putting in, it sees it for the first time and nobody told him anything about it yet. Spring only scans the packages for components, repositories and such, not for @Documents. I am not sure, but I think the mapping is not part of the cluster configuration and therefore the mapping must be specified after cluster startup.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.