문제

I was trying to understand and to work through some example usages of PyES with elastic search when I found this snippet on Object Type: http://packages.python.org/pyes/guide/reference/mapping/object-type.html

In the example JSON:

{
    "tweet" : {
        "person" : {
            "name" : {
                "first_name" : "Shay",
                "last_name" : "Banon"
            },
            "sid" : "12345"
        },
        "message" : "This is a tweet!"
    }
}

"tweet", "person" and "name" are all dicitonaries. Why is it in his example mapping of the object type, he doesn't add "type": "object" to the "name" or "tweet" dictionary, as shown below:

{
    "tweet" : {
        "properties" : {
            "person" : {
                "type" : "object",
                "properties" : {
                    "name" : {
                        "properties" : {
                            "first_name" : {"type" : "string"},
                            "last_name" : {"type" : "string"}
                        }
                    },
                    "sid" : {"type" : "string", "index" : "not_analyzed"}
                }
            }
            "message" : {"type" : "string"}
        }
    }
}
도움이 되었습니까?

해결책

The paragraph under the example states: "In order to mark a mapping of type object, set the type to object. This is an optional step, since if there are properties defined for it, it will automatically be identified as an object mapping." So, I think the example just demonstrates that "type" : "object" is optional.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top