Elasticsearch默认映射(Elasticsearch default mapping)
我目前的理解 -
- Elasticsearch在第一次接收JSON数据集时创建映射索引。
- 无法更改此映射,但可以重新映射数据集。
题-
忘记重新映射。 有没有办法告诉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" } } }
我的“动机”是摆脱
int
和long
类型更改为string
出现的错误。 这会将所有int
和long
值映射为将来创建的所有索引的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-
- Elasticsearch creates the mapping indices the first time it receives the JSON datasets.
- 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
andlong
types change tostring
. Will this map allint
andlong
values asstring
across all indexes that are created in the future? Do i need to nest thisdynamic_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
最满意答案
尝试
$('#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
相关问答
更多-
尝试 $(document).ready(function () { $('#tableid').on('click', 'tr', function (event) { $(this).children().each(function(){ alert($(this).text()) }) }); }); 演示: 小提琴 如果你想要一个数组作为结果 $(document).ready(function ...
-
试试这个。 它应该很明显。 if(AccountEntryDataGrid.SelectedCells.Count == 1) { var selectedColumnHeader = AccountEntryDataGrid.SelectedCells[0].Column.Header.ToString(); } 哎呀...对不起......刚才发现你正在使用MVVM。 将SelectedCells作为命令参数传递。 它应该是IList
类型。 ... -
C#DataGridView右键单击到ContextMenu单击检索单元格值(C# DataGridView Right Click to ContextMenu Click Retrieve Cell Value)[2023-01-22]
如果您要使用该帖子的解决方案,请注意他正在订阅CellMouseDown事件,而不是MouseDown事件。 这有一个不同的签名。 另外,从.Net 2.0开始,你不需要所有的委托包装语法,你只需+=匹配事件委托签名的函数,就像这样: // Your updated MouseDown handler function with DataGridViewCellMouseEventArgs GridView1.CellMouseDown += this.dataGridView_MouseDown; 那么 ... -
您需要将cellClick侦听器添加到面板,这是修改后的代码 var grid1 = Ext.create('Ext.grid.Panel', { renderTo: Ext.getBody(), store: store, width:0.3*Ext.getBody().getViewSize().width, height: 0.5*Ext.getBody().getViewSize().height, columnLines: true, columns: [{ t ...
-
你需要附加听众,例如 listeners: { afterRender: function(p) { p.body.on('click', function() { // Function tapping clicks on Panel alert(p.getTargetEl().dom.innerHTML); ...
-
你可以使用.index() 。 要获取列使用单元格的索引并获取行,其行的索引: $('td').on('click', function() { var row = $(this).closest('tr').index(); var col = $(this).index(); }); 返回的数字是从零开始的,因此row = 0是第一行,col = 0是第一列。 如果要从1开始,请为它们添加1。 jsfiddle DEMO You can use .index(). To get the ...
-
尝试 $('#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', ...
-
在datagrid中单击单元格时查找datagrid列名称(Find datagrid column name when a cell is clicked in datagrid)[2021-11-25]
被点击的原始源并没有真正连接到所谓的项容器 (请参阅DataGrid.ItemContainerGenerator),因此尝试自己动手实现层次结构,尽管一个好主意不会让你走得太远。 对于一个非常愚蠢的简单解决方案,您可以使用它的知识,只有一个单元被单击,因此使用该单击的单元格来检索列,如下所示: private void DataGrid_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { // First check ... -
计算除标题之外的活动单元格上方的列中的所有单元格(Counts all the cells in a column above the active cell excluding the header)[2022-12-10]
尝试这个: Sub counter() Dim col As Integer Dim lastrow As Integer Dim cellcount As Integer With ActiveCell col = .Column lastrow = .Row - 2 End With cellcount = 0 For Each cell In ActiveSheet.Range(Cells(2, col), Cells(lastrow, col)) If IsError ... -
你有正确的想法。 以下是获取列标题的一种方法: Sub ColorFormulaHeaders() Dim oWkbk As Workbook Dim oWkst As Worksheet Dim oRng As Range For Each oRng In Selection.Cells If oRng.HasFormula Then With oRng.EntireColumn.Cells(1).Interior ...