弹性搜索 - 使用'edgeNGram'标记生成器搜索

时间:2013-07-08 10:15:23

标签: java elasticsearch

我是Elastic search的新手,我正在使用JAVA API。 以下是我面临的问题。

以下是设置,我更新了

"settings" : {
  "index.settings.analysis.tokenizer.str_search_tokenizer.max_gram" : "5",
  "index.settings.analysis.tokenizer.str_search_tokenizer.token_chars.1" : "digit",
  "index.settings.analysis.tokenizer.str_search_tokenizer.min_gram" : "2",
  "index.settings.analysis.analyzer.str_search_analyzer.tokenizer" : "str_search_tokenizer",
  "index.settings.analysis.tokenizer.str_search_tokenizer.token_chars.0" : "letter",
  "index.settings.analysis.tokenizer.str_search_tokenizer.type" : "edgeNGram",
  "index.number_of_shards" : "1",
  "index.number_of_replicas" : "2",
  "index.version.created" : "900299"
}

索引来源:

"_source" : {"message":"This message is sample of maximization","messageId":1}

我的搜索邮件代码:

QueryBuilder queryBuilder = QueryBuilders.fuzzyLikeThisQuery("message").likeText("maximizat").analyzer("str_search_analyzer");
FilterBuilder builder = FilterBuilders.queryFilter(queryBuilder);
System.out.println(builder);
SearchResponse response = client.prepareSearch(indexName).setTypes(typeName).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setFilter(builder).execute().actionGet();
System.out.println(response.getHits().getTotalHits());

当我提供像'maximizati','maximizatio','maximization'这样的文本时 - 结果很好。

如果我提供的搜索文本小于10个字符,则结果不会出现。

我需要在elasticsearch.yml文件中更新哪些更改? 或者我的设置JSON或我的搜索查询有什么问题?

0 个答案:

没有答案