作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用path_hierarchy标记生成器为路径编制索引,但它似乎只是标记化了我提供的路径的一半。我尝试了不同的路径,结果似乎是相同的。
我的设置是-
{
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 0,
"analysis":{
"analyzer":{
"keylower":{
"type": "custom",
"tokenizer":"keyword",
"filter":"lowercase"
},
"path_analyzer": {
"type": "custom",
"tokenizer": "path_tokenizer",
"filter": [ "lowercase", "asciifolding", "path_ngrams" ]
},
"code_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [ "lowercase", "asciifolding", "code_stemmer" ]
},
"not_analyzed": {
"type": "custom",
"tokenizer": "keyword",
"filter": [ "lowercase", "asciifolding", "code_stemmer" ]
}
},
"tokenizer": {
"path_tokenizer": {
"type": "path_hierarchy"
}
},
"filter": {
"path_ngrams": {
"type": "edgeNGram",
"min_gram": 3,
"max_gram": 15
},
"code_stemmer": {
"type": "stemmer",
"name": "minimal_english"
}
}
}
}
}
{
"dynamic": "strict",
"properties": {
"depot_path": {
"type": "string",
"analyzer": "path_analyzer"
}
},
"_all": {
"store": "yes",
"analyzer": "english"
}
}
"//cm/mirror/v1.2/Kolkata/ixin-packages/builds/"
作为
depot_path
,我发现 token 形成如下:
"key": "//c",
"key": "//cm",
"key": "//cm/",
"key": "//cm/m",
"key": "//cm/mi",
"key": "//cm/mir",
"key": "//cm/mirr",
"key": "//cm/mirro",
"key": "//cm/mirror",
"key": "//cm/mirror/",
"key": "//cm/mirror/v",
"key": "//cm/mirror/v1",
"key": "//cm/mirror/v1.",
//cm/mirror/v1.2/Kolkata/ixin-packages/builds/
最佳答案
"max_gram": 15
将 token 大小限制为15。如果增加"max_gram"
,您将看到进一步的路径将被 token 化。
以下是我的环境中的示例。
"max_gram" :15
input path : /var/log/www/html/web/
path_analyser tokenized this path upto /var/log/www/ht i.e. 15 characters
"max_gram" :100
input path : /var/log/www/html/web/WANTED
path_analyser tokenized this path upto /var/log/www/html/web/WANTED i.e. 28 characters <100
关于elasticsearch - Elasticsearch path_hierarchy标记路径的一半,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35359579/
抱歉,这很简单,但我自己也无法提出查询或在线找到答案。 如果我的Elasticsearch索引中有一个字段“category”,该字段使用path_hierarchy token 化程序存储分类法结构
我是一名优秀的程序员,十分优秀!