【发布时间】:2020-03-12 06:48:14
【问题描述】:
我的弹性搜索过滤器有问题。我正在尝试使用弹性搜索 DSL 过滤器搜索文本,但我遇到了排序问题。
搜索文字:hello world
文档中的其他字符串:Hello there, hello world, hello everyone, hi hello, etc...
Elasticsearch-dsl 查询是:
MyDocument.search().filter(Q("match", title="hello world") | Q("match", original_title="hello world")).execute()
Elasticsearch 查询是这样的:
{
'bool': {
'filter': [{
'bool': {
'should': [{
'match': {
'title': 'hello world'
}
}, {
'match': {
'original_title': 'hello world'
}
}]
}
}]
}
}
输出类似于hello大家、hi hello、hello world等。
但我想先hello world。
提前致谢!
【问题讨论】:
标签: python django elasticsearch elasticsearch-dsl