2016-07-01 5 views
19

私はKibanaを初めて使用しており、Elastic 5.0.0-alpha3にデータを読み込み、Kibana 5.0.0-alpha3を使用してVisualizeにしています。私は、ヒストグラムなど、いくつかの数値フィールドを表示することができますが、私はテキストフィールドを使用したいとき、私は得る:fieldbata = true in kibana

Visualize: Fielddata is disabled on text fields by default. Set fielddata=true on [publisher] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. 

私はデータ(出版社の名前が)のサブフィールドに分析されている可能性があることを警告していますが、私はしたいのですがとにかく表示する。

fielddata=trueを設定するにはどうすればよいですか?

EDIT:Kibana githubに関する最近の問題は、これが5.0.0の新機能であり、まだ回答を待っていることを示しています。

EDIT(@ Valの答えに続いて、弾力的な初心者の助けを求めて、他の人がそれが役に立つと願っている)EDIT取り込みスクリプトは次のとおりでした:

fs = require('fs') 

var elasticsearch = require('elasticsearch'); 
var client = new elasticsearch.Client({ 
host: 'localhost:9200', 
log: 'trace' 
}); 

fs.readFile('/Users/pm286/workspace/cmdev/getpapers/20160602/crossref_results.json', (err, data) => { 
    if (err) throw err; 
    document = JSON.parse(data) 
    document = JSON.parse(data) 

    for(i=0;i<document.length;i++) { 
     client.create({ 
      index: 'index', 
      type: 'type', 
      body: document[i] 
      }) 
     } 
    }); 

@ Valのアプローチはどのように組み込みますか?あなたのESマッピングで

答えて

26

、あなたはあなたのpublisherフィールドにfielddata:trueを設定する必要があります。

PUT your_index/_mapping/your_type 
{ 
    "your_type": { 
     "properties": { 
     "publisher": { 
      "type": "text", 
      "fielddata": true 
     } 
     } 
    } 
} 

あなたはこの変更を行った後、あなたのデータのインデックスを再作成する必要がありますが、その後Kibanaはもう文句はありません。

:あなたは Sense UIやカール

curl -XPUT http://localhost:9200/index -d '{ 
    "mappings": { 
    "type": { 
     "properties": { 
     "publisher": { 
      "type": "text", 
      "fielddata": true 
     } 
     } 
    } 
    } 
}' 

それとも、また、自分の文書を作成する前に、あなたのJavascriptファイルでそれを実行することができて上記のクエリを実行するか

UPDATE

client.indices.create({ 
    index: 'index', 
    body: { 
     "mappings": { 
     "type": { 
      "properties": { 
      "publisher": { 
       "type": "text", 
       "fielddata": true 
      } 
      } 
     } 
     } 
    } 
}); 
+0

に集約を行うために必要とされます。弾力的な初心者として、私はどのように/これを置くべきかを知っていただければ幸いです。最新の質問を参照してください –

+0

これをテストし、うまくいけばOK。 –

+0

2番目のソースコードブロックに無効なJSONが含まれていますが、動作していません。 – TonyQ

10

あなたがElastic 5.xを使用しているので(5.2を書き留めています)、インデックスフィールドでフィールドデータを有効にする代わりに、新しいキーワードサポートを使用します。

https://www.elastic.co/guide/en/elasticsearch/reference/5.2/fielddata.htmlは、長所と短所、およびこれを設定する方法に関する優れた情報を提供します。ページから :

PUT my_index 
{ 
    "mappings": { 
    "my_type": { 
     "properties": { 
     "my_field": { 
      "type": "text", 
      "fields": { 
      "keyword": { 
       "type": "keyword" 
      } 
      } 
     } 
     } 
    } 
    } 
} 

あなたはその後、検索や集計のための「my_field.keyword」フィールド、並べ替え、またはスクリプトでは「my_field」フィールドを使用します。

my_field.keywordは、Kibana/Grafana内で使用するものです。

5

このコードはこの問題を解決します。

PUT megacorp/_mapping/employee 
{ 
    "employee": { 
     "properties": { 
     "interests": { 
      "type": "text", 
      "fielddata": true 
     } 
     } 
    } 
} 

ので、このコードは、この後に実行されます:

GET /megacorp/employee/_search 
    { 
     "aggs": { 
     "all_interests": { 
      "terms": { "field": "interests"} 
     } 
     } 
    } 
0

は、既存のテキストフィールドにfielddataを有効にし、これはupvoted /受け入れたこのフィールド

PUT megacorp/_mapping/employee 
{ 
    "properties": { 
    "interests": { 
     "type":  "text", 
     "fielddata": true 
    } 
    } 
}