【发布时间】:2016-02-12 17:17:05
【问题描述】:
查询:
GET service/_search
{
"query":{
"match": {"id":1}
}
}
这个查询最终会得到来自弹性搜索服务器的以下结果。我想根据子类别来过滤基于子属性的搜索。我尝试了以下查询,但徒劳无功,其中有什么问题? subCategories nod 是一个数组列表我的意思是jakson转换的列表json转换有什么问题吗?
GET service/_search
{
"query":
{
"match": {
"subCategories.name": "subname1"
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "service",
"_type": "service",
"_id": "1",
"_score": 1,
"_source": {
"id": 1,
"title": "title",
"searchTerms": null,
"description": "description",
"picUrl": "/imgurl",
"price": 65000,
"discount": 10,
"topservice": true,
"place": "100,200",
"status": null,
"subCategories": [
{
"id": 1,
"name": "subname1",
"subCategoryGroup": {
"id": 1,
"name": "Engineering",
"category": {
"id": 1,
"name": "Education"
}
}
},
{
"id": 2,
"name": "subname2",
"subCategoryGroup": {
"id": 1,
"name": "Engineering",
"category": {
"id": 1,
"name": "Education"
}
}
},
{
"id": 3,
"name": "subname3",
"subCategoryGroup": {
"id": 1,
"name": "Engineering",
"category": {
"id": 1,
"name": "Education"
}
}
},
],
"deleted": false
}
}
]
}
}
子类别映射;没有什么特别的,只是一个多对多映射如下
@Field(type= FieldType.Nested)
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "service_subcategory", joinColumns = @JoinColumn(name = "service_id") , inverseJoinColumns = @JoinColumn(name = "subcategory_id") )
private List<SubCategory> subCategories;
【问题讨论】:
-
请分享映射。
-
我已经更新了我的问题
-
请分享您使用
curl -XGET localhost:9200/service/service/_mapping?pretty获得的映射
标签: java json elasticsearch