簡體   English   中英

在[同義詞]下找不到全局令牌過濾器

[英]failed to find global token filter under [synonym]

因此,從此頁面上的文檔來看,似乎我可以使用令牌生成器,令牌過濾器和char過濾器構建自定義的瞬態分析器,並使用Analyze API針對示例文本對其進行測試。

目的是要查看同義詞標記過濾器是否滿足我的需求,即哪些術語被標記為同義詞,哪些不被標記為同義詞。

但是當我這樣做

curl -XGET'localhost:9200 / _analyze?char_filters = html_strip&tokenizer = whitespace&token_filters = synonym'-d'男性和男性相同'

我沒有得到結果,而是得到了

{
  "error": "ElasticsearchIllegalArgumentException[failed to find global token filter under [synonym]]",
  "status": 400
}

有任何想法我在這里做錯了嗎?

由於無法實現“需要索引訪問令牌化程序工廠”的實現,因此當前無法使用臨時同義詞令牌過濾器。 (請參閱elasticsearch Github問題 。)不幸的是,對於在_analyze端點上使用自定義標記過濾器文檔,該限制目前尚未記錄

以下是一些使用重新打開索引的方法創建和更新同義詞標記過濾器的示例命令:

# create index with filter
curl -v -X PUT -s -H 'Content-Type: application/json' 'localhost:9200/syn_test_idx' -d '
{
  "settings" : {
    "analysis" : {
      "filter" : {
        "test_synonym_filter" : {
          "type" : "synonym",
          "synonyms" : [
            "i-pod, i pod => ipod",
            "universe, cosmos"
          ]
        }
      }
    }
  }
}

# test token filter
' | jq .
curl -X POST -s -H 'Content-Type: application/json' 'localhost:9200/syn_test_idx/_analyze' -d '{
  "tokenizer": "standard",
  "filter": ["global_synonym_filter"],
  "text": "cow i phone"
}' | jq .

(“ i phone”沒有被同義詞列表捕獲。)

# update index
curl -X POST -s 'localhost:9200/syn_test_idx/_close' | jq .
curl -X PUT -s -H 'Content-Type: application/json' 'localhost:9200/syn_test_idx/_settings' -d '{
  "analysis" : {
    "filter": {
      "test_synonym_filter":{
        "type":"synonym",
        "synonyms" : [
          "i-pod, i pod => ipod",
          "universe, cosmos",
          "i-phone, i phone => iphone"
        ]
      }
    }
  }
}' | jq .
curl -X POST -s 'localhost:9200/syn_test_idx/_open' | jq .

# test token filter
' | jq .
curl -X POST -s -H 'Content-Type: application/json' 'localhost:9200/syn_test_idx/_analyze' -d '{
  "tokenizer": "standard",
  "filter": ["global_synonym_filter"],
  "text": "cow i phone"
}' | jq .

(“ iphone”通過同義詞列表翻譯為“ iphone”。)

(在不相關的注釋上,由於某種原因,我的zsh / YADR設置未顯示后期響應正文,因此我通過jq其傳遞。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM