2

I'm using Spring-Data-ElasticSearch to index a whole object as a document in Elastic. One of the field is a String typed base64 encoding of user upload file.

@Document(indexName = "user_record")
public class UserRecord {

    private String base64UserUploadFile;

...

Currently this base64 string is indexed directly into Elastic so not searchable, so I'm wondering what's my options here if I want to be able to search the actual content from that file without having to convert this field to be the actual file content string in my class?

1 Answer 1

1

You might want to use the mapper-attachments plugin and declare your field with the Attachment field type

@Document(indexName = "user_record")
public class UserRecord {

    @FieldType(type = FieldType.Attachment, store = false)
    private String base64UserUploadFile;

...

That way the Base64 content will be indexed and searchable. I suggest not to store the content (hence store=false) if you don't want to inflate your index unnecessarily.

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

2 Comments

Have you been able to try this out?
Sorry I haven't been able to get it working. I did look into it but turned out the ES used in our current project is too old, 1.7.2, with Spring Data ES 1.5 which doesn't have native support for mapper-attachment. So right now I'm trying to upgrade ES but some effort is needed as this ES is used by other components in our project as well.

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.