如何在elasticsearch中使用path_hierarchy analyzer查询字段?

时间:2017-04-06 08:23:09

标签: elasticsearch tokenize analyzer elasticsearch-analyzers

我已使用以下配置在elasticsearch中配置了path_analyzer。

Column_A1 column_A2 num_match
 A1         10        1
 A2         20        1
 A3         30        2

现在我插入了四个路径值为的文档:

  • /角度/结构
  • /角度/结构/指令
  • /角度/结构/组件
  • /角度/物流

现在我想查询我的索引,例如:

  1. 它只会检索PUT /elastic_course { "settings": { "analysis": { "analyzer": { "path_analyzer": { "tokenizer": "path_tokenizer" }, "reverse_path_analyzer": { "tokenizer": "path_tokenizer" } }, "tokenizer": { "path_tokenizer": { "type": "path_hierarchy", "delimiter": "/", "replacement": "-" }, "reverse_path_tokenizer": { "type": "path_hierarchy", "delimiter": "/", "replacement": "-" } } } }, "mappings": { "book" : { "properties": { "author": { "type": "string", "index": "not_analyzed" }, "genre": { "type": "string", "index": "not_analyzed" }, "score": { "type": "double" }, "synopsis": { "type": "string", "index":"analyzed", "analyzer":"english" }, "title": { "type": "string" }, "path":{ "type":"string", "analyzer":"path_analyzer", "fields": { "reverse": { "type":"string", "analyzer":"reverse_path_analyzer" } } } } } } }
  2. 的子项
  3. 它将返回所有叶节点,即structuralcomponentsdirectives
  4. 我尝试在查询下运行,但它会检索所有记录。

    logistics

    任何帮助?

    感谢。

0 个答案:

没有答案