4

我刚刚组织了我的文档结构,使其具有更多的面向对象设计(例如,将顶级属性(如venueId和)移动venueName到具有和字段的venue对象中)。idname

但是,我现在无法获得适用于子venue内部对象上的字段的简单术语过滤器。

这是我的映射:

{
    "deal": {
        "properties": {
            "textId": {"type":"string","name":"textId","index":"no"},
            "displayId": {"type":"string","name":"displayId","index":"no"},
            "active": {"name":"active","type":"boolean","index":"not_analyzed"},
            "venue": {
                "type":"object",
                "path":"full",
                "properties": {
                    "textId": {"type":"string","name":"textId","index":"not_analyzed"},
                    "regionId": {"type":"string","name":"regionId","index":"not_analyzed"},
                    "displayId": {"type":"string","name":"displayId","index":"not_analyzed"},
                    "name": {"type":"string","name":"name"},
                    "address": {"type":"string","name":"address"},
                    "area": {
                        "type":"multi_field",
                        "fields": {
                            "area": {"type":"string","index":"not_analyzed"},
                            "area_search": {"type":"string","index":"analyzed"}}},
                    "location": {"type":"geo_point","lat_lon":true}}},
            "tags": {
                "type":"multi_field",
                "fields": {
                    "tags":{"type":"string","index":"not_analyzed"},
                    "tags_search":{"type":"string","index":"analyzed"}}},
            "days": {
                "type":"multi_field",
                "fields": {
                    "days":{"type":"string","index":"not_analyzed"},
                    "days_search":{"type":"string","index":"analyzed"}}},
            "value": {"type":"string","name":"value"},
            "title": {"type":"string","name":"title"},
            "subtitle": {"type":"string","name":"subtitle"},
            "description": {"type":"string","name":"description"},
            "time": {"type":"string","name":"time"},
            "link": {"type":"string","name":"link","index":"no"},
            "previewImage": {"type":"string","name":"previewImage","index":"no"},
            "detailImage": {"type":"string","name":"detailImage","index":"no"}}}
}

这是一个示例文档:

GET /production/deals/wa-au-some-venue-weekends-some-deal

{
    "_index":"some-index-v1",
    "_type":"deals",
    "_id":"wa-au-some-venue-weekends-some-deal",
    "_version":1,
    "exists":true, 
    "_source" : {
        "id":"921d5fe0-8867-4d5c-81b4-7c1caf11325f",
        "textId":"wa-au-some-venue-weekends-some-deal",
        "displayId":"some-venue-weekends-some-deal",
        "active":true,
        "venue":{
            "id":"46a7cb64-395c-4bc4-814a-a7735591f9de",
            "textId":"wa-au-some-venue",
            "regionId":"wa-au",
            "displayId":"some-venue",
            "name":"Some Venue",
            "address":"sdgfdg",
            "area":"Swan Valley & Surrounds"},
        "tags":["Lunch"],
        "days":["Saturday","Sunday"],
        "value":"$1",
        "title":"Some Deal",
        "subtitle":"",
        "description":"",
        "time":"5pm - Late"
    }
}

这是对同一文档的“解释”测试:

POST /production/deals/wa-au-some-venue-weekends-some-deal/_explain

{
    "query": {
        "filtered": {
            "filter": {
                "term": {
                    "venue.regionId": "wa-au"
                }
            }
        }
    }
}

{
    "ok":true,
    "_index":"some-index-v1",
    "_type":"deals",
    "_id":"wa-au-some-venue-weekends-some-deal",
    "matched":false,
    "explanation":{
        "value":0.0,
        "description":"ConstantScore(cache(venue.regionId:wa-au)) doesn't match id 0"
    }
}

有什么方法可以获得更有用的调试信息?解释结果描述有问题吗?简单地说“不匹配 id 0”对我来说真的没有意义......该字段被称为“regionId”(不是“id”)并且值绝对不是 0......???

4

1 回答 1

5

发生这种情况是因为您提交映射的类型被调用deal,而您索引文档的类型被调用deals

如果您查看您的 type 的映射deals,您会看到它是自动生成的,并且字段venue.regionId 已被分析,因此您的索引中很可能有两个标记:waau。只有在该类型上搜索那些标记,您才能返回该文档。

其他任何东西看起来都很棒!只有一个小字符是错误的;)

于 2013-07-29T10:13:17.900 回答