pythonElasticSearchBadRequestError,同时进行不敏感匹配分析器

ct3nt3jp  于 2023-02-17  发布在  Python
关注(0)|答案(1)|浏览(181)

我正在尝试建立一个索引,它可以搜索到不区分大小写的精确匹配,Elasticsearch版本是8.6.2,Lucene版本是9.4.2,代码在Python中运行,带有Python的elasticsearch库。

settings = {"settings": {
    "analysis": {
      "analyzer": {"lower_analizer": {"tokenizer": "whitespace", "filter": [ "lowercase" ]} }
    }
  }
}

mappings = {"properties": {
                "title": {"type": "text", "analyzer": "standard"},
                "article": {"type": "text", "analyzer": "lower_analizer"},
                "sentence_id": {"type": "integer"},
    }
}

我从Elasticsearch's tutorial复制了设置。但是,它返回了以下错误:

BadRequestError: BadRequestError(400, 'illegal_argument_exception', 
'unknown setting [index.settings.analysis.analyzer.lower_analizer.filter]
 please check that any required plugins are installed, or check the
 breaking changes documentation for removed settings')

我不知道从哪里继续,因为它暗示小写函数不存在?

yacmzcpb

yacmzcpb1#

standard分析器中,默认有小写过滤器。
文本字段类型使用标准分析器

PUT test_stackoverflow/_doc/1
{
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

GET test_stackoverflow/_search
{
  "query": {
    "match": {
      "text": "quick"
    }
  }
}

答复:

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "test_stackoverflow",
        "_id": "1",
        "_score": 0.2876821,
        "_source": {
          "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
        }
      }
    ]
  }
}

图像结果:

相关问题