Skip to content

Instantly share code, notes, and snippets.

@itayw
Last active October 18, 2015 09:20
Show Gist options
  • Select an option

  • Save itayw/d453d06dde8a4fa5e9ae to your computer and use it in GitHub Desktop.

Select an option

Save itayw/d453d06dde8a4fa5e9ae to your computer and use it in GitHub Desktop.
Kibana highlighting
itay@joola-laptop:~/dev/kibana$ cat diff.txt
diff --git a/src/kibana/components/doc_table/components/table_row.js b/src/kibana/components/doc_table/components/table_row.js
index 1595284..e9bf8ed 100644
--- a/src/kibana/components/doc_table/components/table_row.js
+++ b/src/kibana/components/doc_table/components/table_row.js
@@ -153,7 +153,14 @@ define(function (require) {
function _displayField(row, fieldName, breakWords) {
var indexPattern = $scope.indexPattern;
var text = indexPattern.formatField(row, fieldName);
+ text = '';
+ row.highlight.content.forEach(function(h){
+ text += '...' + h.replace(/\r\n/ig,' ').replace(/\n/ig,' ').replace(/\r/ig,' ') ;
+ });
+ text = text.replace(/@kibana-highlighted-field@/ig,'<mark>');
+ text = text.replace(/@\/kibana-highlighted-field@/ig,'</mark');
+ console.log('text',text);
if (breakWords) {
text = addWordBreaks(text, MIN_LINE_LENGTH);
diff --git a/src/kibana/components/highlight/highlight.js b/src/kibana/components/highlight/highlight.js
index cfe92e7..2438ee3 100644
--- a/src/kibana/components/highlight/highlight.js
+++ b/src/kibana/components/highlight/highlight.js
@@ -7,6 +7,8 @@ define(function (require) {
module.filter('highlight', function (highlightTags) {
return function (formatted, highlight) {
+ //console.log('format', formatted, highlight);
+ //console.trace();
if (typeof formatted === 'object') formatted = angular.toJson(formatted);
_.each(highlight, function (section) {
diff --git a/src/kibana/plugins/discover/controllers/discover.js b/src/kibana/plugins/discover/controllers/discover.js
index 4ee3820..c3e9797 100644
--- a/src/kibana/plugins/discover/controllers/discover.js
+++ b/src/kibana/plugins/discover/controllers/discover.js
@@ -426,7 +426,8 @@ define(function (require) {
pre_tags: [highlightTags.pre],
post_tags: [highlightTags.post],
fields: {'*': {}},
- fragment_size: 2147483647 // Limit of an integer.
+ fragment_size: 250,
+ number_of_fragments: 3
})
.set('filter', queryFilter.getFilters());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment