我们在映射中使用了minimal_english
词干分析器。这是为了确保只有单数和复数是可搜索的而不是相似的单词。例如。在输入字词Test
时,Tests
和Test
应该可搜索 - 但Tester
,Testers
,Testing
不应该。在尝试使用以下RESTful API进行搜索时,multi_field
属性类型是可搜索的,但nested
属性类型不是:
curl -X GET "http://10.113.124.136:9400/libtester/_search?pretty=true" -d '{
"query": {
"query_string": {
"query": " DescriptionDescription ",
"fields": [
"abc"
]
}
}
}'
映射如下所示:
{
"properties": {
"abc": {
"type": "multi_field",
"fields": {
"c_asset_id": {
"type": "string",
"index": "analyzed",
"include_in_all": true,
"analyzer": "basic_english"
},
"untouched": {
"type": "string",
"index": "analyzed",
"include_in_all": false,
"analyzer": "string_lowercase"
}
}
},
"xyz": {
"type": "nested",
"properties": {
"c_viewpoint": {
"type": "multi_field",
"fields": {
"c_viewpoint": {
"type": "string",
"index": "analyzed",
"include_in_all": true,
"analyzer": "basic_english"
},
"untouched": {
"type": "string",
"index": "analyzed",
"include_in_all": false,
"analyzer": "string_lowercase"
}
}
}
}
},
...
}
}
这是否与嵌套类型的映射有关 - xyz,它们不能从多字段类型的同一API中搜索到?
答案 0 :(得分:1)
您可以搜索嵌套属性,只需要稍微不同的语法。您必须指定路径,然后显式使用您要搜索的每个属性的路径。