gpt4 book ai didi

elasticsearch - ElasticSearch:设置search_analyzer时,必须在字段上设置Analyzer

转载 作者:行者123 更新时间:2023-12-04 05:54:27 39 4
gpt4 key购买 nike

我已经阅读过ES(<2)的早期版本,其中“token_analyzer”键需要更改为“analyzer”。但是无论我做什么我仍然会收到此错误:

"type": "mapper_parsing_exception",
"reason": "analyzer on field [email] must be set when search_analyzer is set"

这是我收到错误时通过PUT函数传递给ES的内容:
{ 
"settings": {
"analysis": {
"analyzer": {
"my_email_analyzer": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": ["lowercase", "stop"]
}
}
}
},
"mappings" : {
"uuser": {
"properties": {
"email": {
"type": "text",
"search_analyzer": "my_email_analyzer",
"fields": {
"email": {
"type": "text",
"analyzer": "my_email_analyzer"
}
}
},
"facebookId": {
"type": "text"
},
"name": {
"type": "text"
},
"profileImageUrl": {
"type": "text"
},
"signupDate": {
"type": "date"
},
"username": {
"type": "text"
}
,
"phoneNumber": {
"type": "text"
}
}

}
}
}

任何想法有什么问题吗?

最佳答案

因为您已经为该字段指定了 search_analyzer ,所以您还必须指定在建立索引时要使用的分析器。例如,将以下行添加到您指定search_analyzer的位置:

"analyzer": "standard",

给你这个:
{ 
"settings": {
"analysis": {
"analyzer": {
"my_email_analyzer": {
"type": "custom",
"tokenizer": "uax_url_email",
"filter": ["lowercase", "stop"]
}
}
}
},
"mappings" : {
"uuser": {
"properties": {
"email": {
"type": "text",
"search_analyzer": "my_email_analyzer",
"analyzer": "standard",
"fields": {
"email": {
"type": "text",
"analyzer": "my_email_analyzer"
}
}
},
"facebookId": {
"type": "text"
},
"name": {
"type": "text"
},
"profileImageUrl": {
"type": "text"
},
"signupDate": {
"type": "date"
},
"username": {
"type": "text"
}
,
"phoneNumber": {
"type": "text"
}
}

}
}
}

另请参阅: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html

关于elasticsearch - ElasticSearch:设置search_analyzer时,必须在字段上设置Analyzer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51023630/

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