0

我在 Elastic Search 中为我的索引定义了以下映射,其中包含一种 multi_field 类型。

{
    'station': {
       "properties" :{
           'id': {'type': 'integer'},
           'call': {'type': 'multi_field', 
                    'fields' : {
                               'call': {'type': 'string', 'analyzer': 'whitespace'},
                               'raw': {'type': 'string', 'index': 'not_analyzed'}
                               }
                    }
        }
    }
}

我喜欢 Mozilla 的 ElasticUltis,但我找不到查询 multi_field 字段的方法。

我本来期望像这样的:

myQuery = S.query(call_raw__wildcard="value")

有谁知道如何使用 elasticutils 查询 multi_field 字段?

4

2 回答 2

0

First, your multi_field definition is incorrect. You should have a call main field at the same level as raw and autocomplete. See the multi_field docs.

Then you can query the main field as call, and the raw field as call.raw.

于 2014-02-03T11:09:19.307 回答
0

好的 - 我在 multi_field文档 (tnx @DrTech) 中找到了解决方法。如果添加了“path”:“just_name”,则可以在没有“call”前缀的情况下访问该字段(在问题“call.raw”中)。然后映射将如下所示:

{
'station': {
   "properties" :{
       'id': {'type': 'integer'},
       'call': {'type': 'multi_field', 
                'path' : 'just_name',
                'fields' : {
                           'call': {'type': 'string', 'analyzer': 'whitespace'},
                           'raw': {'type': 'string', 'index': 'not_analyzed'}
                           }
                }
    }
}

}

不幸的是,这只是一种解决方法。也许其他人有更好的主意?

于 2014-02-03T13:59:47.670 回答