5

I am unable to create a custom mapping for "hashtags," which is a subfield of "twitter_entities" in elasticsearch. I tried to do it in the following ways:

 {
    "mappings": {
        "tweet" : {
            "properties": {
                "twitter_entities.hashtags" : {
                    "type" : "multi_field",
                    "fields" : {
                        "hashtag" : {
                            "type" : "string",
                            "analyzer" : "hashtag"
                        },                        
                        "autocomplete" : {
                            "type" : "string",
                            "index_analyzer" : "hashtag_autocomplete",
                            "search_analyzer" : "hashtag"   
                        }
                    }
                }
            }   
        }
    }
}

This creates another root field called "twitter_entities.hashtags"

 {
    "mappings": {
        "tweet" : {
            "properties": {
                "hashtags" : {
                    "type" : "multi_field",
                    "fields" : {
                        "hashtag" : {
                            "type" : "string",
                            "analyzer" : "hashtag"
                        },                        
                        "autocomplete" : {
                            "type" : "string",
                            "index_analyzer" : "hashtag_autocomplete",
                            "search_analyzer" : "hashtag"   
                        }
                    }
                }
            }   
        }
    }
}

and

{
    "mappings": {
        "tweet" : {
            "properties": {
                "_parent" : {"type" : "twitter_entities" },
                "hashtags" : {
                    "type" : "multi_field",
                    "fields" : {
                        "hashtag" : {
                            "type" : "string",
                            "analyzer" : "hashtag"
                        },                        
                        "autocomplete" : {
                            "type" : "string",
                            "index_analyzer" : "hashtag_autocomplete",
                            "search_analyzer" : "hashtag"   
                        }
                    }
                }
            }   
        }
    }
}

both just create another root field called "hashtags".

I am unable to find any documentation in the elasticsearch api or forums about doing this. Could anyone point me in the right direction?

4

1 に答える 1

10

マッピングのドキュメント、特にオブジェクト タイプに関するページを参照してください。ルート オブジェクト ( ) に対して行ったのと同じように、オブジェクトとして定義twitter_entitiesし、そのフィールドを で宣言するだけです。他のフィールドを含むフィールドはオブジェクトとして検出されるため、タイプを省略できます。propertiestwitter_entitiesobjectproperties

{
    "mappings": {
        "tweet" : {
            "properties": {
                "twitter_entities" : {
                    "type": "object",
                    "properties" : {
                        "hashtag" : {
                            "type" : "multi_field",
                            "fields" : {
                                "hashtag" : {
                                "type" : "string",
                                "analyzer" : "hashtag"
                                },                        
                                "autocomplete" : {
                                    "type" : "string",
                                    "index_analyzer" : "hashtag_autocomplete",
                                    "search_analyzer" : "hashtag"   
                                }
                            }
                        }
                    }
                }
            }   
        }
    }
}
于 2013-09-13T21:38:08.250 に答える