P
P
poznavaka2020-03-10 15:50:37
Java
poznavaka, 2020-03-10 15:50:37

How to use Similarity Elasticsearch in Springframework?

I am using similarity like scripted_tfidf in Elasticsearch. I need to specify this for a field in a model in Springframework. Before version 4.0.0 , using the @Field annotation, this was not possible, in version 4.0.0, Similarity enum has 4 types, as I understand it, not one of them is suitable? Is it possible for me to somehow specify using Spring or should I pay attention to some other libraries?
Maybe I should specify mapping using json? Similarly:

@Setting(settingPath = "/path/to/settings.json")
@Document(indexName = "indexName")
public class IndexClass {

    @Id
    private String id;
    private String name;

    // getters and setters
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
poznavaka, 2020-03-10
@poznavaka

Similarity enum types are not suitable by default. Version 4.0.0 has not yet been released, but it also does not have the ability to use similarity with the string type, so it makes no sense for scripted_tfidf to use it. Therefore, the only normal option is to create mapping using json from resource:

@Mapping(mappingPath = "/mapping.json")
@Setting(settingPath = "/settings.json")
@Document(indexName = "indexName")
public class IndexClass {
    @Id
    private String id;
    private String name;

    // getters and setters
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question