【问题标题】:Elasticsearch language Analyzers - return the retrieved field after text analysisElasticsearch 语言分析器 - 文本分析后返回检索到的字段
【发布时间】:2020-06-29 13:05:48
【问题描述】:
  1. 我正在研究 Elasticsearch 中的全文搜索引擎,并在索引时间内使用多语言数据。我使用弹性搜索进行文本分析,我希望能够在预处理后返回令牌(检索到的索引)。我知道分析 API,但是对 +200.000 个文档执行此操作非常耗时。我找到了“术语聚合”,但我不确定它是如何工作的。有什么想法吗?

  2. 我在映射语言分析器中使用。使用语言分析器或每个文档都通过每个语言分析器时是否有任何开箱即用的语言检测?如果是这样,使用语言检测并为每种语言创建多字段是否有意义?在设置或映射中使用语言分析器有什么区别?

PUT /index_sample
{
  "settings": {
    "analysis" : {
      "analyzer" : {
        "my_analyzer" : {
          "type" : "custom",
          "tokenizer" : "standard",
          "filter" : [
            "my_asciifolding",
            "my_apostrophe",
            "cjk_bigram"]
        }
      },
      "filter" : {
        "my_asciifolding" : {
          "type" : "asciifolding",
          "preserve_original" : true
        },
        "my_apostrophe" :{
        "type" : "apostrophe"
        }
      }
    }
  },
  "mappings" : {
    "properties": {
      "category_number" : {
        "type" : "integer",
        "fields" : {
          "raw" : {
          "type" : "keyword"
          }
        }
      },
      "product": {
        "type" : "text",
        "index" : "true",
        "store" : "true",
        "analyzer" : "my_analyzer",
        "fields" : {
          "german_field": {
            "type" : "text",
            "analyzer": "german"
          },
          "english_field" : {
            "type" : "text",
            "analyzer" : "english"
          },
          "chinese_field" : {
            "type" : "text",
            "analyzer" : "smartcn"
          },
          "spanish_field": {
            "type" : "text",
            "analyzer" : "spanish"
          },
          "czech_analyer" : {
            "type" : "text",
            "analyzer" : "czech"
          },
          "french_field": {
            "type" : "text",
            "analyzer" : "french"
          },
          "italian_field" : {
            "type" : "text",
            "analyzer" : "italian"
          },
          "dutch_field": {
            "type" : "text",
            "analyzer" : "dutch"
          },
          "portuguese_field": {
            "type" : "text",
            "analyzer" : "portuguese"
          }
        }  
      }
    }
  }
}

【问题讨论】:

  • 为什么要返回文档中的所有标记?你在寻找几个 known_vocabulary_tokens 吗?
  • 将令牌存储在数组字段中会让您满意吗?
  • 我想看看我的索引字段在文本分析后的样子

标签: elasticsearch nlp


【解决方案1】:

如果您想查看索引字段的外观 你也可以使用 _analysis API(我相信你不想这样做)


或者你可以看看_termvectors

GET /<index_name>/_termvectors/<doc_id>?fields=<filed_name>

【讨论】:

    【解决方案2】:

    回答你的第二个问题


    在设置或映射中使用语言分析器有什么区别?


    Index/_settings/analyzer : 为您的索引定义分析器

    一旦你定义了你的分析器,然后在映射中你可以定义如何以及何时使用这个分析器
    分析器与特定字段相关联,可以在索引时或搜索时使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多