Elastic 1.5,在AWS上运行。我正在尝试运行以下查询:
GET /pictures_testing/_search
{
"query": {
"filtered": {
"query": {
"wildcard": {
"aircraft_type_search.search": {
"wildcard": "piper"
}
}
}
}
}
}
但它没有返回任何结果。但是我可以从aircraft_type_search获得结果,而不是从aircraft_type_search.search映射
这是字段映射:
{
"pictures_testing": {
"mappings": {
"picture": {
"aircraft_type_search": {
"full_name": "aircraft_type_search",
"mapping": {
"aircraft_type_search": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}
}
我有其他字段以相同的方式设置,.search映射将返回结果(包括通配符查询,这是最终点)所以我有点不知道为什么这个字段没有。
GET / pictures_testing / return:
{
"pictures_testing": {
"aliases": {},
"mappings": {
"picture": {
"properties": {
"ab_archive": {
"type": "string"
},
"ab_publication": {
"type": "string"
},
"aircraft_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"aircraft_type": {
"type": "string"
},
"aircraft_type_search": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"aircraft_verified": {
"type": "string"
},
"airport": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"airshow": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"airshow_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"airshow_verified": {
"type": "string"
},
"approved": {
"type": "integer",
"ignore_malformed": true
},
"category": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"code_number": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"construction_number": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"country": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"created_by": {
"type": "string"
},
"created_on": {
"type": "string"
},
"date_added": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy-MM-dd HH:mm:ss"
},
"date_approved": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy-MM-dd HH:mm:ss"
},
"date_taken": {
"type": "string"
},
"date_taken_formatted": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy-MM-dd HH:mm:ss"
},
"display_picture": {
"type": "string"
},
"displayed_info": {
"type": "string"
},
"displayteam": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"displayteam_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"displayteam_verified": {
"type": "string"
},
"editors_choice": {
"type": "string"
},
"email": {
"type": "string"
},
"filename": {
"type": "string"
},
"full_size_folder": {
"type": "string"
},
"group": {
"type": "string"
},
"hidden_email": {
"type": "string"
},
"hidden_photographer": {
"type": "string"
},
"id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"information": {
"type": "string"
},
"initial": {
"type": "string"
},
"ip": {
"type": "string"
},
"location_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"location_verified": {
"type": "string"
},
"manufacturer": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"military_unit": {
"type": "string"
},
"model": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"modified_by": {
"type": "string"
},
"modified_on": {
"type": "string"
},
"name": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"operator": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"operator_category_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"operator_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"operator_type": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"operator_verified": {
"type": "string"
},
"original_filename": {
"type": "string"
},
"photographer": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"index": "not_analyzed",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"picture_category_id": {
"type": "integer",
"ignore_malformed": true,
"null_value": -1
},
"picture_id": {
"type": "string"
},
"picturecategory_verified": {
"type": "string"
},
"registration": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"reject_reason": {
"type": "string"
},
"site_name": {
"type": "string"
},
"slug": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"subtype": {
"type": "string"
},
"subtype2": {
"type": "string"
},
"type": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"index": "not_analyzed"
}
}
},
"uploaded_file_size": {
"type": "string"
},
"verified": {
"type": "string"
},
"views": {
"type": "integer",
"ignore_malformed": true
},
"website": {
"type": "string"
},
"year": {
"type": "integer",
"ignore_malformed": true
}
}
}
},
"settings": {
"index": {
"creation_date": "1487318302366",
"analysis": {
"analyzer": {
"case_insensitive_sort": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1",
"version": {
"created": "1050299"
},
"uuid": "KoaR8mksTReY_2mRu4wi-Q"
}
},
"warmers": {}
}
}
应匹配的示例文档:
{
"_index": "pictures_testing",
"_type": "picture",
"_id": "1328215",
"_score": 1,
"_source": {
"id": "1328215",
"aircraft_id": "8947",
"operator_id": "3273",
"operator_category_id": "3",
"location_id": "2877",
"displayteam_id": null,
"airshow_id": null,
"picture_category_id": "4",
"military_unit": "",
"registration": "9M-AQJ",
"code_number": "",
"construction_number": "28-7125042",
"date_taken": "9th March 1975",
"date_taken_formatted": "1975-03-09 00:00:00",
"year": "1975",
"information": "A rather hazy slide being a long shot in 34c.",
"approved": null,
"display_picture": "yes",
"reject_reason": "",
"editors_choice": "no",
"ab_publication": "",
"ab_archive": "no",
"correction_id": null,
"correction_reason": null,
"correction_status": null,
"correction_rejection_reason": null,
"views": "159",
"created_on": "0000-00-00 00:00:00",
"created_by": "0",
"modified_on": "0000-00-00 00:00:00",
"modified_by": null,
"date_approved": "2012-01-02 18:58:07",
"initial": "P",
"manufacturer": "Piper",
"type": "Piper PA-28 / 28R Cherokee",
"model": "Piper PA-28-140 Cherokee D",
"subtype": "Fixed Wing - Propeller",
"subtype2": "Light Aircraft",
"verified": "1",
"operator": "Private",
"operator_type": "Company",
"airport": "Kota Kinabalu International (BKI / WBKK)",
"country": "Malaysia",
"deleted_on": null,
"deleted_by": null,
"slug": "general",
"name": "General",
"displayteam": null,
"airshow": null,
"category": "Light Aircraft",
"group": "A",
"picture_id": "1328215",
"aircraft_verified": "1",
"aircraft_type": "Piper PA-28 / 28R Cherokee",
"operator_verified": "1",
"location_verified": "1",
"displayteam_verified": null,
"airshow_verified": null,
"picturecategory_verified": "1",
"aircraft_type_search": "Piper PA-28 / 28R Cherokee Piper PA-28-140 Cherokee D"
}
},
{
"_index": "pictures_testing",
"_type": "picture",
"_id": "1328213",
"_score": 1,
"_source": {
"id": "1328213",
"aircraft_id": "5302",
"operator_id": "3273",
"operator_category_id": "3",
"location_id": "2877",
"displayteam_id": null,
"airshow_id": null,
"picture_category_id": "4",
"military_unit": "",
"registration": "9M-ANZ",
"code_number": "",
"construction_number": "28-20740",
"date_taken": "9th March 1975",
"date_taken_formatted": "1975-03-09 00:00:00",
"year": "1975",
"information": "-",
"approved": null,
"display_picture": "yes",
"reject_reason": "",
"editors_choice": "no",
"ab_publication": "yes",
"ab_archive": "no",
"correction_id": null,
"correction_reason": null,
"correction_status": null,
"correction_rejection_reason": null,
"views": "126",
"created_on": "0000-00-00 00:00:00",
"created_by": "0",
"modified_on": "0000-00-00 00:00:00",
"modified_by": null,
"date_approved": "2012-01-02 18:56:27",
"initial": "P",
"manufacturer": "Piper",
"type": "Piper PA-28 / 28R Cherokee",
"model": "Piper PA-28-140 Cherokee",
"subtype": "Fixed Wing - Propeller",
"subtype2": "Light Aircraft",
"verified": "1",
"operator": "Private",
"operator_type": "Company",
"airport": "Kota Kinabalu International (BKI / WBKK)",
"country": "Malaysia",
"deleted_on": null,
"deleted_by": null,
"slug": "general",
"name": "General",
"displayteam": null,
"airshow": null,
"category": "Light Aircraft",
"group": "A",
"picture_id": "1328213",
"aircraft_verified": "1",
"aircraft_type": "Piper PA-28 / 28R Cherokee",
"operator_verified": "1",
"location_verified": "1",
"displayteam_verified": null,
"airshow_verified": null,
"picturecategory_verified": "1",
"aircraft_type_search": "Piper PA-28 / 28R Cherokee Piper PA-28-140 Cherokee"
}
},
任何人都知道这里可能出现的问题?
答案 0 :(得分:0)
你不应该使用" not_analyzed"在该字段的映射" aircraft_type_search.search"。 " not_analyzed"仅当您要搜索字段完全时,才会使用相同的大小写。
如果你想要结果" Piper PA-28 / 28R Cherokee Piper PA-28-140切诺基"当你搜索" piper"然后将映射更改为:
"aircraft_type_search": {
"type": "string",
"fields": {
"lower_case_sort": {
"type": "string",
"analyzer": "case_insensitive_sort"
},
"search": {
"type": "string",
"analyzer": "standard" // CHANGE HERE
}
}
}
然后您不必使用通配符查询。只需使用匹配查询。
GET /pictures_testing/_search
{
"query": {
"filtered": {
"query": {
"match": {
"aircraft_type_search.search": "piper"
}
}
}
}
}
这将寻找" piper"在" aircraft_type_search"字段,并将匹配您的搜索。