Here is my schema:

{
    "settings": {
        "index": {
            "analysis": {
                "analyzer": {
                    "starts_with": {
                        "tokenizer": "keyword",
                        "filter": "lowercase"
                    },
                    "str_search_analyzer": {
                        "tokenizer": "keyword",
                        "filter": "lowercase"
                    },
                    "str_index_analyzer": {
                        "tokenizer": "keyword",
                        "filter": ["lowercase", "substring"]
                    },
                    "reverse": {
                        "tokenizer": "keyword",
                        "filter": "reverse"
                    }
                },
                "filter": {
                    "substring": {
                        "type": "nGram",
                        "min_gram": 1,
                        "max_gram": 20
                    }
                }
            }
        }
    },
    "mappings": {
        "fruits": {
            "dynamic_templates" : [
                {
                    "template_1" : {
                        "match" : "*",
                        "match_mapping_type" : "string",
                        "mapping": {
                            "type": "object",
                            "index": "not_analyzed",
                            "properties": {
                                "flesh": {
                                    "type": "string",
                                    "index": "not_analyzed"
                                },
                                "sweet": {
                                    "type": "boolean"
                                },
                                "seed": {
                                    "type": "string",
                                    "index" : "not_analyzed"
                                },
                                "skin": {
                                    "type": "string",
                                    "index" : "not_analyzed"
                                }
                            }
                        }
                    }
                },
                {
                    "template_2": {

                        "match": "multi*",
                        "fields": {
                            "{name}": {
                                "type": "string",
                                "index": "analyzed"
                            },
                            "starts_with_{name}": {
                                "type": "string",
                                "index": "not_analyzed",
                                "analyzer": "starts_with"
                            },
                            "equals_{name}": {
                                "type": "string",
                                "index": "not_analyzed"
                            },
                            "contains_{name}": {
                                "type": "string",
                                "search_analyzer": "str_search_analyzer",
                                "index_analyzer": "str_index_analyzer"
                            },
                            "ends_with_{name}": {
                                "type": "string",
                                "analyzer": "reverse"
                            }
                        }
                    }
                }

            ]
        }
    }
}


On Thu, Mar 27, 2014 at 10:14 AM, Parag Shah <[email protected]> wrote:

> Hi Kevin,
>
>     I tried this. Does not seem to work for me. Do you have a working
> example? Also, remember, fruits is essentially  a map. I also need to be
> able to search the keys in this map.
>
> Regards
> Parag
>
> On Wednesday, March 26, 2014 3:13:03 PM UTC-7, Kevin Wang wrote:
>>
>> I think you can use Dynamic template for that http://www.elasticsearch.
>> org/guide/en/elasticsearch/reference/current/mapping-
>> root-object-type.html#_dynamic_templates
>>
>>
>> Regards,
>> Kevin
>>
>> On Thursday, March 27, 2014 9:03:55 AM UTC+11, Parag Shah wrote:
>>>
>>> Hi all,
>>>
>>> {
>>> "fruits" : {
>>> "apple" : {
>>> "sweet" : true,
>>> "color" : "red",
>>> "seed" : "red",
>>> "flesh" : "white"
>>> },
>>> "orange" : {
>>> "sweet" : true,
>>> "color" : "orange",
>>> "seed" : "white",
>>> "flesh" : "orange"
>>> }
>>> }
>>> }
>>>
>>> The above is what I want to generate mappings for.
>>>
>>> fruits is the container for different kinds of fruits.
>>>
>>> I could add any other fruit (unknown) to "fruits" (known) like:
>>>
>>> "banana" : {
>>>      "sweet" : true,
>>>      "color" : "yellow",
>>>      "seed" : "black",
>>>      "flesh" : "white"
>>> }
>>>
>>> banana is a user-generated value, and for any fruit here and it has some
>>> attributes like sweet, color, seed and flesh.
>>>
>>> I am not sure how I would do the mapping for this kind of a structure.
>>> Any help will be appreciated.
>>>
>>> Regards
>>> Parag
>>>
>>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "elasticsearch" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elasticsearch/aplw3dpwe00/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/55357ca1-4226-4fdd-a759-7d09a0e2a6fb%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/55357ca1-4226-4fdd-a759-7d09a0e2a6fb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAD2b%2BQ3v36ZLFwcmh0LfiCwc-hF9ZOobdtASq7TtPT5-xg21ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to