elasticsearch Elasticsearch span_near无法按预期工作
我有一个Elasticsearch索引,其结构如下: 示例条目:
elasticsearch Elasticsearch span_near无法按预期工作,
elasticsearch,search,n-gram,
elasticsearch,Search,N Gram,我有一个Elasticsearch索引,其结构如下: 示例条目: { 'ID': '1', 'creator': 'Sam', 'instance': 'court of cassation', 'text': [ { 'depth: 0, 'role': 'introduction', 'caseText': ['27', 'october', 'decision', 'of', 'the', 'high', 'court', 'in
{
'ID': '1',
'creator': 'Sam',
'instance': 'court of cassation',
'text': [
{
'depth: 0,
'role': 'introduction',
'caseText': ['27', 'october', 'decision', 'of', 'the', 'high', 'court', 'in', 'the', 'case', 'of']
'ngrams': ['in_the', 'case_of']
},
{
'depth: 1,
'role': 'decision',
'caseText': ['we', 'decide', 'a', 'sentence', 'of', 'three', 'weeks']
'ngrams': ['three_weeks']
},
]
}
在我的示例中,我面临的问题是“高等法院”未注册为ngram,因此我希望执行一个搜索,其中我强制高等法院
和法院
在案例文本
字段中彼此相邻
我尝试使用span_near
查询执行此操作,但没有结果:
{
"query": {"span_near": {
clauses": [
"span_term": { "text.caseText": 'high'}},
"span_term": { "text.caseText": 'court'}},
],
"slop": 0,
"in_order": True
}
}
}
恐怕我对span_near
查询的理解有点错误,但我真的需要它来工作。非常感谢您的帮助