首页 \ 问答 \ Elasticsearch默认映射(Elasticsearch default mapping)

Elasticsearch默认映射(Elasticsearch default mapping)

我目前的理解 -

  1. Elasticsearch在第一次接收JSON数据集时创建映射索引。
  2. 无法更改此映射,但可以重新映射数据集。

题-

忘记重新映射。 有没有办法告诉ES 默认行为 -

"Consider everything that is not a date to be of string type"

另外,如果我这样做,我会失去很多吗?

最新情况:

我添加了file- config/mappings/_default/mapping.json以及以下内容 -

{
    "dynamic_templates": [
        {
            "template_1": {
                "match": "*",
                "match_mapping_type": "int",
                "mapping": {
                    "type": "string"
                }
            },
            "template_2": {
                "match": "*",
                "match_mapping_type": "long",
                "mapping": {
                    "type": "string"
                }
            }
        }
    ]
}

我也试过放置以下at- config/default_mapping.json

{
    "_default_" : {
        "match": "*",
        "match_mapping_type": "int",
        "mapping": {
                "type": "string"
        }
    }
}

我的“动机”是摆脱intlong类型更改为string出现的错误。 这会将所有 intlong值映射为将来创建的所有索引的string吗? 我是否需要在_all嵌套此dynamic_templates键?

更新II-

添加此映射文件会导致弹性搜索咳嗽 -

[2014-02-04 10:48:34,396][DEBUG][action.admin.indices.create] [Her] [logstash-2014.02.04] failed to create
org.elasticsearch.index.mapper.MapperParsingException: mapping [mapping.json]
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:312)
    at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:298)
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:135)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Map
    at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:268)
    at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:155)
    at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:314)
    at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:193)
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:309)
    ... 5 more
2014-02-04 10:48:34 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2014-02-04 10:48:33 +0000 error_class="Net::HTTPServerException" error="400 \"Bad Request\"" instance=17509700

My current understanding-

  1. Elasticsearch creates the mapping indices the first time it receives the JSON datasets.
  2. This mapping cannot be changed, but the datasets can be re-mapped.

Question-

Forget re-mapping. Is there any way to tell ES to behave by default as-

"Consider everything that is not a date to be of string type"?

Also, will i be losing out on much if i do this?

Update-

i added the file- config/mappings/_default/mapping.json with the following contents-

{
    "dynamic_templates": [
        {
            "template_1": {
                "match": "*",
                "match_mapping_type": "int",
                "mapping": {
                    "type": "string"
                }
            },
            "template_2": {
                "match": "*",
                "match_mapping_type": "long",
                "mapping": {
                    "type": "string"
                }
            }
        }
    ]
}

i also tried placing the following at- config/default_mapping.json

{
    "_default_" : {
        "match": "*",
        "match_mapping_type": "int",
        "mapping": {
                "type": "string"
        }
    }
}

My 'motive' is to get rid of errors that crop up if int and long types change to string. Will this map all int and long values as string across all indexes that are created in the future? Do i need to nest this dynamic_templates key within _all?

Update II-

Adding this mapping file causes elasticsearch to cough up-

[2014-02-04 10:48:34,396][DEBUG][action.admin.indices.create] [Her] [logstash-2014.02.04] failed to create
org.elasticsearch.index.mapper.MapperParsingException: mapping [mapping.json]
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:312)
    at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:298)
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:135)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Map
    at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:268)
    at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:155)
    at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:314)
    at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:193)
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:309)
    ... 5 more
2014-02-04 10:48:34 +0000 [warn]: temporarily failed to flush the buffer. next_retry=2014-02-04 10:48:33 +0000 error_class="Net::HTTPServerException" error="400 \"Bad Request\"" instance=17509700

原文:https://stackoverflow.com/questions/21544527
更新时间:2023-12-09 17:12

最满意答案

尝试

$('#table tbody td').click(function (event) {
    var th = $('#users-table th').eq($(this).index());
    if (th.text() != 'no action') {
        if (event.target.type !== 'checkbox') {
            $(this).closest('tr').find(':checkbox').prop('checked', function (i, checked) {
                return !checked;
            })
        }
    }
});

演示: 小提琴


但您可以使用事件委派模型跳过第3列中的单击事件

$('#table tbody').on('click', 'td:not(:nth-child(3))', function (event) {
    if (event.target.type !== 'checkbox') {
        $(this).closest('tr').find(':checkbox').prop('checked', function (i, checked) {
            return !checked;
        })
    }
});

演示: 小提琴


Try

$('#table tbody td').click(function (event) {
    var th = $('#users-table th').eq($(this).index());
    if (th.text() != 'no action') {
        if (event.target.type !== 'checkbox') {
            $(this).closest('tr').find(':checkbox').prop('checked', function (i, checked) {
                return !checked;
            })
        }
    }
});

Demo: Fiddle


But you can use event delegation model to skip the click event in the 3rd columnd

$('#table tbody').on('click', 'td:not(:nth-child(3))', function (event) {
    if (event.target.type !== 'checkbox') {
        $(this).closest('tr').find(':checkbox').prop('checked', function (i, checked) {
            return !checked;
        })
    }
});

Demo: Fiddle

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。