【问题标题】:elasticsearch nested multi_field not_analyzed not workingelasticsearch嵌套的multi_field not_analyzed不起作用
【发布时间】:2014-05-23 08:24:53
【问题描述】:

我有一个问题已经好几个小时了,我只是没有得到解决。

我需要进行构面搜索以获取所有视频播放列表的列表。

一个视频可以有多个播放列表,分别是“名称”、“位置”。这就是它嵌套的原因。

这是我的映射:

{
   "mappings" : {
    "test" : {
         "properties" : {
             "playlists": {
                 "type": "nested",
                 "properties" : {
                     "name" : {
                         "type": "multi_field",
                         "fields" : {
                             "name": {"type" : "string", "index" : "analyzed", "store": "yes"},
                             "untouched" : {"type" : "string", "index" : "not_analyzed"}
                         }
                     },
                     "position" : {
                         "type" : "string"
                     }
                 }
             }
            }
         }
    }
}

问题在于名称包含“-”时。例如具有以下方面搜索的“de-classic”:

{
  "query": {
    "match_all": {}
  },
  "facets": {
    "playlists": {
      "terms": {
        "field": "playlists.name",
        "size": 1000
      }
    }
  }
}

我的构面搜索返回一个“de”条目和一个“classic”条目:

facets: {
    playlists: {
        _type: terms,
        missing: 0,
        total: 2,
        other: 0,
        terms: [
            {
                term: de
                count: 1
            },
            {
                term: classics
                count: 1
            }
        ]
    }
}

我在这里放了一个简化的要点:https://gist.github.com/axeff/bacf3bb2119f7589e612

Elasticsearch v1.1.1

编辑:

而且我插入后的映射看起来不像我创建的映射:

curl localhost:9200/videos/test/_mapping?pretty=true:

{
  "videos" : {
    "mappings" : {
      "test" : {
        "properties" : {
          "playlists" : {
            "properties" : {
              "name" : {
                "type" : "string"
              },
              "position" : {
                "type" : "string"
              }
            }
          }
        }
      }
    }
  }
}

【问题讨论】:

    标签: elasticsearch nested mapping facets


    【解决方案1】:

    解决了我的问题:

    {
      "query": {
        "match_all": {}
      },
      "facets": {
        "playlists": {
          "terms": {
            "field": "playlists.name",
            "size": 1000
          },
          "nested": "playlists"  // <- that's what I was missing!
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2015-09-09
      • 1970-01-01
      • 2016-05-08
      • 2017-06-16
      相关资源
      最近更新 更多