3

にクエリを投稿していますがhttp://localhost:9200/movie_db/movie/_search、_source 属性は常に空です。有効にしましたが、役に立ちません。

映画DB:

TRY DELETE /movie_db
PUT /movie_db {"mappings": {"movie": {"properties": {"title": {"type": "string", "analyzer": "snowball"}, "actors": {"type": "string", "position_offset_gap" : 100, "analyzer": "standard"}, "genre": {"type": "string", "index": "not_analyzed"}, "release_year": {"type": "integer", "index": "not_analyzed"}, "description": {"_source": true, "type": "string", "analyzer": "snowball"}}}}}
BULK INDEX movie_db/movie
{"_id": 1, "title": "Hackers", "release_year": 1995, "genre": ["Action", "Crime", "Drama"], "actors": ["Johnny Lee Miller", "Angelina Jolie"], "description": "High-school age computer expert Zero Cool and his hacker friends take on an evil corporation's computer virus with their hacking skills."}
{"_id": 2, "title": "Johnny Mnemonic", "release": 1995, "genre": ["Science Fiction", "Action"], "actors": ["Keanu Reeves", "Dolph Lundgren"], "description": "A guy with a chip in his head shouts incomprehensibly about room service in this dystopian vision of our future."}
{"_id": 3, "title": "Swordfish", "release_year": 2001, "genre": ["Action", "Crime"], "actors": ["John Travolta", "Hugh Jackman", "Halle Berry"], "description": "A cast of characters challenge society's commonly held view that computer experts are not the beautiful people. Somehow, the CIA is hacked in under 5 minutes."}
{"_id": 4, "title": "Tomb Raider", "release_year": 2001, "genre": ["Adventure", "Action", "Fantasy"], "actors": ["Angelina Jolie", "Jon Voigt"], "description": "The story of a girl and her quest for antiquities in the face of adversity. This epic is adapter from its traditional video-game format to the big screen"}

クエリ:

{
    "query" : 
    {
        "term" : { "genre" : "Crime" }
    },
}

結果:

{
    "took": 4,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 2,
        "max_score": 0.30685282,
        "hits": [
            {
                "_index": "movie_db",
                "_type": "movie",
                "_id": "3",
                "_score": 0.30685282,
                "_source": {}
            },
            {
                "_index": "movie_db",
                "_type": "movie",
                "_id": "1",
                "_score": 0.30685282,
                "_source": {}
            }
        ]
    }
}
4

3 に答える 3

1

_source同じ問題がありました。クエリとマッピングで有効にしても、_source常に{}.

Elasticsearch.yml で cluster.name を設定するという提案された解決策は、問題が古いクラスターの隠された設定にあるに違いないというヒントを与えてくれました。

インストールしたプラグイン(私の場合はelasticsearch-transport-couchbase)に付属のインデックステンプレート定義があることがわかりました。

    "_source" : {
      "includes" : [ "meta.*" ]
    },

これにより、ソース以外のすべてのフィールドが暗黙的に除外さmeta.*れます。

次のようにテンプレートを確認します。

curl -XGET localhost:9200/_template/?pretty

couchbaseこんな感じでテンプレートを削除しました

curl -XDELETE localhost:9200/_template/couchbase

新しい、ほぼ同じものを作成しましたが、source有効にしました。

方法は次のとおりです: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

于 2015-11-17T13:39:48.713 に答える
0

解決:

elasticsearch 構成フォルダーで、elasticsearch.yml を開き、cluster.name を別の値に設定してから、elasticsearch.bat を再起動します。

于 2013-08-14T16:47:12.513 に答える