Elasticsearch:在不添加索引映射的情况下测试自定义分析器

时间:2018-05-20 20:48:46

标签: elasticsearch

我可以测试自定义elasticsearch analyzer / tokenizer而无需先将其添加到索引中吗? 类似的东西:

                         _______________ _______________
a.view really results in 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 (binary 2 then 1)
                                                     513

我可以通过首先在索引中添加一个新的分析器来测试它 -

path-to-regexp

然后这样做 -

GET _analyze
{
  "tokenizer": {
        "my_custom_tokenizer": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 10,
          "token_chars": [
          "letter", "digit", "symbol"

          ]
        }
      },
  "text" : "this is a test"
}

我可以避免这两步过程吗?

1 个答案:

答案 0 :(得分:2)

据我所知,早期版本的Elasticsearch(如2.x)不支持像这样的复杂数组/对象分析,但更新的版本如5.x及更高版本肯定会这样做。

你几乎在那里使用你现有的JSON请求,只需删除“my_custom_tokenizer”对象,同时保持其当前配置:

{
  "tokenizer" : {
    "type": "edge_ngram", 
    "min_gram": 2, 
    "max_gram": 10, 
    "token_chars": ["letter", "digit", "symbol"]
  },

  "text" : "this is a test"
}