4

補完機能を備えた単純な検索アプリに取り組んでいます。これらの提案をどうにかして保護する必要があるため、最も簡単な方法は、コンプリート サジェスターにコンテキストを追加することであると考えました。私の問題は、ネストされたフィールドでサジェスタ コンテキストを使用する方法がわからないことです。

これは、私のマッピングがどのように見えるか、非常に単純で、3 つのフィールドと 1 つのネストされたものです。

curl-XPUT'http: //localhost: 9200/cr/_mapping/agreement_index'-d'{
    "agreement_index": {
        "properties": {
            "agreement_name": {
                "type": "string",
                "fields": {
                    "suggest": {
                        "type": "completion",
                        "analyzer": "simple",
                        "payloads": false,
                        "preserve_separators": true,
                        "preserve_position_increments": true,
                        "max_input_length": 50,
                        "context": {
                            "permitted": {
                                "type": "category",
                                "path": "permitted",
                                "default": []
                            }
                        }
                    }
                }
            },
            "permitted": {
                "type": "integer"
            },
            "team": {
                "type": "nested",
                "dynamic": "false",
                "properties": {
                    "email": {
                        "type": "string",
                        "fields": {
                            "raw": {
                                "type": "string",
                                "index": "not_analyzed"
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "simple",
                                "payloads": false,
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50,
                                "context": {
                                    "permitted": {
                                        "type": "category",
                                        "path": "permitted",
                                        "default": []
                                    }
                                }
                            }
                        }
                    },
                    "name": {
                        "type": "string",
                        "fields": {
                            "raw": {
                                "type": "string",
                                "index": "not_analyzed"
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "simple",
                                "payloads": false,
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50,
                                "context": {
                                    "permitted": {
                                        "type": "category",
                                        "path": "permitted",
                                        "default": []
                                    }
                                }
                            }
                        }
                    },
                    "permitted": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}'

次のようなドキュメントのインデックス作成中:

curl-XPUT'http: //localhost: 9200/cr/agreement_index/1'-d'{
    "agreement_name": "QWERTY",
    "team": [{
        "name": "Tomasz Sobkowiak",
        "permitted": ["2"],
        "email": "tsobkowiak@fake.com"
    }],
    "permitted": ["2"]
}'

以下のエラーが発生しました:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"one or more prefixes needed"}],"type":"illegal_argument_exception","reason":"one or more prefixes needed"},"status":400}

ネストされたフィールドの補完候補からコンテキストを削除すると、すべて正常に機能します。私の質問は、パスが外側のドキュメントのフィールドを指しているネストされたフィールドでコンテキスト サジェスターをどのように使用できるかということです。そのようなことさえ可能ですか?

4

1 に答える 1