我正在尝试定义一个默认分析器,用于索引类似的类型:
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 jersey
和penn state jerseys
会返回不同的搜索结果,即使我认为他们应该返回相同的内容,因为球衣不应该是复数。