gpt4 book ai didi

elasticsearch - Elasticsearch默认分析器无法分析

转载 作者:行者123 更新时间:2023-12-03 00:11:05 27 4
gpt4 key购买 nike

我正在尝试为以下类型的索引定义默认分析器:

curl -X PUT "http://localhost:9200/index" -d '{
"index" : {
"analysis" : {
"filter": {
"english_stop": {
"type": "stop",
"stopwords": "_english_"
},
"english_stemmer": {
"type": "stemmer",
"language": "english"
},
"english_possessive_stemmer": {
"type": "stemmer",
"language": "possessive_english"
}
},
"analyzer" : {
"default" : {
"tokenizer" : "standard",
"filter": [
"standard",
"english_possessive_stemmer",
"lowercase",
"english_stop",
"english_stemmer"
]
}
}
}
}
}'

但是,当搜索这些类型时,似乎未对文档进行分析,因为字段中的值未小写,未词干且不删除停用词。难道我做错了什么?我正在尝试分析文档而不定义文档结构。这个 page使我相信,设置默认的分析器索引应该可以分析我插入到 index/_type中的文档。

更新:
curl -X PUT "http://localhost:26319/index" -d '{
"settings" : {
"analysis" : {
"filter": {
"english_stop": {
"type": "stop",
"stopwords": "_english_"
},
"english_stemmer": {
"type": "stemmer",
"language": "english"
},
"english_possessive_stemmer": {
"type": "stemmer",
"language": "possessive_english"
}
},
"analyzer" : {
"default" : {
"tokenizer" : "standard",
"filter": [
"standard",
"english_possessive_stemmer",
"lowercase",
"english_stop",
"english_stemmer"
]
}
}
}
}
}'

这是我正在运行的搜索:
curl -X GET "http://localhost:9200/index/_type/_search?q=penn+state+jersey&pretty"

这是映射:
{
"index" : {
"mappings" : {
"_type" : {
"properties" : {
"description" : {
"type" : "string"
},
"keyphrases_general" : {
"type" : "string"
},
"keyphrases_specific" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"unique_id" : {
"type" : "string"
},
"vendor" : {
"type" : "string"
}
}
}
}
}
}

这是一个文档示例:
{
"_index" : "index",
"_type" : "_type",
"_id" : "518875234",
"_score" : 1.1152786,
"_source" : {
"keyphrases_specific" : "Office Merchandise Tailgating Outdoor Clothing Man Cave",
"name" : "Penn State Nittany Lions Classic Football Keychain - Licensed NCAA Gift - Penn State Nittany Lions Merchandise",
"description" : "Check out this Penn State Nittany Lions Classic Football Keychain - Licensed NCAA Gift - Penn State Nittany Lions Merchandise. This product is perfect for a Penn State Nittany Lions fan. Show off your pride and add a great piece to your man cave! Made By Gamewear",
"keyphrases_general" : "Sports Bedding Drinkware Licensed D�cor Accessories Gift",
"vendor" : null,
"unique_id" : null
}
}

这也很奇怪,因为 penn state jerseypenn state jerseys返回不同​​的搜索结果,尽管我认为由于 Jersey 不再是复数,所以它们应该返回相同的搜索结果。

最佳答案

您有一个小错字:JSON的第一层上index应该是settings

curl -X PUT "http://localhost:9200/index" -d '{
"settings" : { <--- change this
"analysis" : {
"filter": {

确保先删除您的索引,然后重试,这将起作用。

关于elasticsearch - Elasticsearch默认分析器无法分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40647085/

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