gpt4 book ai didi

elasticsearch - 在Elastic搜索中基于定界符对字符串进行标记

转载 作者:行者123 更新时间:2023-12-02 23:29:20 25 4
gpt4 key购买 nike

我需要使用36-3031.00|36-3021.00分隔符将字符串36-3031.00标记化为36-3021.00|

我已经尝试过了

PUT text
{
"test1": {
"settings": {
"analysis" : {
"tokenizer" : {
"pipe_tokenizer" : {
"type" : "pattern",
"pattern" : "|"
}
},
"analyzer" : {
"pipe_analyzer" : {
"type" : "custom",
"tokenizer" : "pipe_tokenizer"
}
}
}
},
"mappings": {
"mytype": {
"properties": {
"text": {
"type": "string",
"analyzer": "pipe_analyzer"
}
}
}
}
}}

但它不会产生确切的结果。谁能解决这个用例?

最佳答案

以下是您应该使用的正确映射(包括REST PUT命令中的索引名称)。并且|字符需要转义:

DELETE test1
PUT test1
{
"settings": {
"analysis": {
"tokenizer": {
"pipe_tokenizer": {
"type": "pattern",
"pattern": "\\|"
}
},
"analyzer": {
"pipe_analyzer": {
"type": "custom",
"tokenizer": "pipe_tokenizer"
}
}
}
},
"mappings": {
"mytype": {
"properties": {
"text": {
"type": "string",
"analyzer": "pipe_analyzer"
}
}
}
}
}

POST /test1/mytype/1
{"text":"36-3031.00|36-3021.00"}

GET /test1/_analyze
{"field":"text","text":"36-3031.00|36-3021.00"}

关于elasticsearch - 在Elastic搜索中基于定界符对字符串进行标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38346913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com