Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch Elasticsearch span_near无法按预期工作_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Search_N Gram - Fatal编程技术网 elasticsearch Elasticsearch span_near无法按预期工作,elasticsearch,search,n-gram,elasticsearch,Search,N Gram" /> elasticsearch Elasticsearch span_near无法按预期工作,elasticsearch,search,n-gram,elasticsearch,Search,N Gram" />

elasticsearch Elasticsearch span_near无法按预期工作

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

我有一个Elasticsearch索引,其结构如下:

示例条目:

{
  '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
查询的理解有点错误,但我真的需要它来工作。非常感谢您的帮助