我的 elasticsearch_dsl 类中有一些我想查询完全匹配的东西:
class Profile(DocType):
name = String(fields={'raw': String(index='not_analyzed')})
虽然这确实有效,但我总是需要.raw
在查询中添加一个并且无法name
准确查询:
# Matches "foo" and "foo-1"
Profile.search().filter('term', name='foo'})
# Matches nothing
Profile.search().filter('term', name='foo-1'})
# Matches what i want (only "foo-1")
Profile.search().filter('term', **{'name.raw': 'foo-1'})
这感觉有点不对,因为我应该只能使用name
而不是raw
,因为它应该是一样的。
什么是正确的方法?