elasticsearch - 用于设置索引“否”的 Elasticsearch 使用哪种类型,关键字或文本?
问题描述
Elasticsearch 设置 "index": "no", with "index": false "type", "keyword" OR "text" 应该用什么会有什么区别吗?
因为由于该字段未编入索引,我认为不会有任何区别?
解决方案
在 Elasticsearch 2.x 或Elasticsearch > 5.x 中将index
选项设置为不会为该字段创建倒排索引,这意味着您无法对其执行搜索或过滤。但是您可以通过创建一个名为using doc_values的数据视图来进行排序和聚合,这是该字段的重要性。 我通过将字段设置为一次和下一次来创建并运行搜索查询。no
false
fielddata
type
my_index
text_or_keyword_field
type
text
keyword
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"text_or_keyword_field": {
"type": "keyword",
"index": "false"
}
}
}
}
}
Elasticsearch 提出了一个search_phase_execution_exception
给出预期的原因:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"match\" : {\n \"text_or_keyword_field\" : {\n \"query\" : \"brown fox\",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n \"auto_generate_synonyms_phrase_query\" : true,\n \"boost\" : 1.0\n }\n }\n}",
"index_uuid": "hz4Vq6mPRaCc9HSxB-MEYg",
"index": "my_index"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "my_index",
"node": "LvCoGAkyTbiVIeyF7UtXTw",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"match\" : {\n \"text_or_keyword_field\" : {\n \"query\" : \"brown fox\",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n \"auto_generate_synonyms_phrase_query\" : true,\n \"boost\" : 1.0\n }\n }\n}",
"index_uuid": "hz4Vq6mPRaCc9HSxB-MEYg",
"index": "my_index",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Cannot search on field [text_or_keyword_field] since it is not indexed."
}
}
}
]
},
"status": 400
}
推荐阅读
- user-interface - 我现在安装了 Visual Studio 2019,问题是我没有在 Visual C++ 中获得 UI 或 Windows 表单选项
- javascript - Discord.js UnhandledPromiseRejectionWarning:DiscordAPIError:无法发送空消息
- html - CSS - 斜线与空格的空白控制
- rest - 修改kotlin中Swagger Codegen方法的contentHeaders
- reactjs - 无法在 setState 上将隐藏列状态从 true 更改为 false
- sumo - 我可以通过traci获取SUMO中车辆的蓝牙数据吗?
- php - 如何在 PHP 中使用 PLAID 实现 Stripe ACH
- sql - SQL错误:过多coalesce导致BCD溢出
- ios - iOS ARKit ARFaceAnchor 导出到具有实际面部大小的 3D 模型文件?
- javascript - 根据开始值和结束值对数字数组进行排序