0

I'm relatively new to ES and am having difficulty finding really good references or tutorials on the query dsl.

We have a document type of the example below. The query I wish to conduct is thus: "Return all the email_package records that have at least one entities record (one record in the 'entities' array)." And yes I want the complete 'email' record.

Could anyone assist? Also if you could point to a reference or tutorial or cookbook somewhere that addresses question like this, that would be also greatly appreciated.

"email_package": {
                    "email": {
                        "date": "2007-02-13T18:24:22-04:00",
                        "subject": "this is the subject",
                        "body": "this is the body"
                    },
                    "entities": [
                        {
                            "Louisville": {
                                "City": "South"
                            }
                        },
                        {
                            "Memphis": {
                                "City": "South"
                            }
                        }
                    ]
               }
                // more 'email_package records follow...
4

1 に答える 1

1

オブジェクトをネストして異なる名前を付けているように見えるため、ドキュメントには少し問題があります。現在の構造に縛られていない場合は、マッピングをより管理しやすいものに変更し、クエリは簡単になります。たとえば、次のようになります。

"email_package": {
    "email": {
        "body": "this is the body1", 
        "date": "2007-02-13T18:24:22-04:00", 
        "subject": "this is the subject"
    }, 
    "entities": [
        {
            "name": "Louisville"
            "City": "South", 
         }, 
        {
            "name": "Memphis"                 
            "City": "South", 
        }
    ]
}

クエリ:

{ "filter": {
    "exists": {
        "field": "email_package.entities.name"
    }
 }
于 2013-03-11T15:53:59.690 に答える