弹簧靴弹性搜索中的n-gram实现

弹簧靴弹性搜索中的n-gram实现,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我正在尝试在elasticsearch中实现自动完成,我在spring boot中使用它,我已经尝试了很多,尝试了很多来自internet的示例,但无法实现。下面是我的代码示例,请帮助我 主要类别:- @SpringBootApplication @EnableNatsAnnotations @EnableAutoConfiguration @EnableConfigurationProperties(ElasticsearchProperties.class) @EntityScan(base

我正在尝试在elasticsearch中实现自动完成,我在spring boot中使用它,我已经尝试了很多,尝试了很多来自internet的示例,但无法实现。下面是我的代码示例,请帮助我

主要类别:-

@SpringBootApplication
@EnableNatsAnnotations
@EnableAutoConfiguration
@EnableConfigurationProperties(ElasticsearchProperties.class)
@EntityScan(basePackages = {
        "com.text.model"
})
@ComponentScan(
        {
                "com.text.elastic",
                "com.text.elastic.controller",
                "com.text.elastic.service",
                "com.text.elastic.service.impl",
                "com.text.nats.utils"
        }
)
public class ElasticServicesApplication {

    public static void main(String[] args) {
        SpringApplication.run(ElasticServicesApplication.class, args);
    }
}
Bean类:-

@Setting(settingPath = "elasticsearch-settings.json")
@Document(indexName = "content", type = "content", shards = 1, replicas = 0, createIndex = true,   refreshInterval = "-1")
public class Content {

    @Id
    private String id;

    private Locale locale;

   // @Field(type = text, index = true, store = true, analyzer = "standard")
    @Field(
            type = FieldType.String,
            index = FieldIndex.analyzed,
            searchAnalyzer = "standard",
            //indexAnalyzer = "type_ahead",
            analyzer = "standard"

            /*,
            store = true*/
    )
    private String contentTitle;
这里我想在contentTitle中实现它。

Mapping 使用注释的简明方法:

@CompletionField()
private Completion suggest;
或者更强大但乏味的方式:

{
    "content" : {
        "properties" : {
            "contentTitle" : { "type" : "string" },
            "suggest" : { "type" : "completion",
                "analyzer" : "simple",
                "search_analyzer" : "simple"
            }
        }
    }
}


//Then refer to the mapping by `@Mapping`:
@Setting(settingPath = "elasticsearch-settings.json")
@Document(indexName = "content", type = "content", shards = 1, replicas = 0, createIndex = true,   refreshInterval = "-1")
@Mapping(mappingPath = "/mappings/content-mapping.json")
public class Content {...}
索引 我们可以将索引作为我们的共同实体:

esTemplate.save(new File(...));
质疑
ElasticsearchTemplate
具有查询建议的方法:

public SuggestResponse suggest(SuggestBuilder.SuggestionBuilder<?> suggestion, String... indices);
public SuggestResponse suggest(SuggestBuilder.SuggestionBuilder建议,字符串…索引);
裁判