12

ElasticSearchにSolrcopyFieldディレクティブに相当するものがあるかどうか誰かに教えてもらえますか?

マルチフィールドタイプがあることは知っています: http ://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html 同じフィールドに複数のアナライザーを適用する場合に便利です。

しかし、それはまったく同じではありません。Solrは、複数のフィールドを1つに「マージ」することを許可します。

<field name="id" type="string" indexed="true" stored="true"/>
<field name="name" type="string" indexed="true" stored="true"/>
<field name="subject" type="string" indexed="true" stored="true"/>
<field name="location" type="string" indexed="true" stored="true"/>
<field name="all" type="text" indexed="true" stored="true" multiValued="true"/>
<copyField source="*" dest="all"/>

このプラグインはかなり有望です: https ://github.com/yakaz/elasticsearch-analysis-combo

ElasticSearchの複数値フィールドを使用すると、結果を単一のフィールドとして返すことができるためです。ただし、複数のフィールドを「マージ」することはできないため、まったく同じではありません。


ComboアナライザーとSolrcopyFieldの両方の組み合わせが欲しいのですが。

ブログ投稿モデル(タイトル/説明フィールド)があり、2つの異なるアナライザーを適用する単一のフィールド「blogContent」にタイトルと説明の両方をコピーしたいと思います。

ElasticSearchに解決策はありますか?

4

2 に答える 2

8

デフォルトで他のすべてのフィールドのコピーを取得する特別な_allフィールドがあります。属性_allを使用して、フィールドへの包含を制御できます。include_in_allただし、このようなフィールドは1つに制限されています。複数のフィールドが必要な場合は、複数のフィールドを検索して検索側で処理する必要があります。

次の属性を使用multi_fieldして、copyFieldと同様の機能を実現することもできます。"path": "just_name"

curl -XPUT localhost:9200/test-idx -d '{
    "settings": {
        "index": {
            "number_of_shards": 1,
            "number_of_replicas": 0
        }
    },
    "mappings": {
        "doc": {
            "properties": {
                "first_name": {
                    "type": "multi_field",
                    "path": "just_name",
                    "fields": {
                        "first_name": {"type": "string", "index": "analyzed"},
                        "name": {"type": "string","index": "analyzed"}
                    }
                },
                "last_name": {
                    "type": "multi_field",
                    "path": "just_name",
                    "fields": {
                        "last_name": {"type": "string", "index": "analyzed"},
                        "name": {"type": "string","index": "analyzed"}
                    }
                }
            }
        }
    }
}'
echo
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
    "first_name": "Sebastien",
    "last_name": "Lorber"
}'
echo
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/doc/_search?q=name:Sebastien"
echo
curl "localhost:9200/test-idx/doc/_search?q=name:Lorber"
于 2012-10-29T14:49:35.967 に答える
6

Elastic SearchはcopyToをサポートしています:

コピー先のフィールドにアナライザーを追加できます。

于 2014-03-20T13:35:48.820 に答える