Elasticsearch。嵌套嵌套的嵌套查询

时间:2015-10-19 22:53:35

标签: php elasticsearch nested

我的映射是(部分):

$index =  [
"mappings" => [
    "goods" => [
        "dynamic_templates"=> [
                        [
                            "iattribute_id"=> [
                                "match_mapping_type"=> "string",
                                "match"=>   "attribute_id",
                                "mapping"=> [
                                    "type"=> "integer"
                                ]
                            ]
                        ],
                        [
                            "iattribute_value"=> [
                                "match_mapping_type"=> "string",
                                "match"=>   "attribute_value",
                                "mapping"=> [
                                    "type"=> "string",
                                    "index" => "not_analyzed"
                                ]
                            ]
                        ]
                    ],
        "properties" => [
            ...
            "individual_attributes" => [
                            "type" => "nested",
                            "properties" => [
                                "template_id" => ["type" => "integer"],
                                "attributes_set" => [
                                    "type" => "nested",
                                    "properties" => [
                                        "attribute_id" => ["type" => "integer"],
                                        "attribute_value" => ["type" => "string", "index" => "not_analyzed"]
                                    ]
                                ]
                            ]
                        ]
            ...
        ]
    ]
]
];

如何查询attribute_idattribute_value?它们嵌套在嵌套中。我无法理解如何指定字段的路径。 我已经编写了查询但它不起作用。

GET /index/type/_search
{
"query" : {
  "nested" : {
    "path" : "individual_attributes.attributes_set",
    "score_mode" : "none",
      "filter": {
        "bool": {
          "must": [
            {
              "term" : {
                "individual_attributes.attributes_set.attribute_id": "20"
              }
            },
            {
              "term" : {
                "individual_attributes.attributes_set.attribute_value": "commodi"
              }
            }
          ]
        }
      }
    }
  }

}

1 个答案:

答案 0 :(得分:1)

试试这个:

<VirtualHost *:80>
    ServerName domain2.com
    ServerAlias www.domain2.com *.domain2.com domain2.ca *.domain2.ca
    DocumentRoot /git/domain2.com/public/
    ServerAdmin webmaster@domain2.com

    <Directory /git/domain2.com/public/>
        Options +Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/apache2/error_domain2.com.log
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>

        ServerAdmin webmaster@domain2.com
        ServerName domain2.com
        DocumentRoot /git/domain2.com/public/

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
        SSLCertificateFile /git/domain2.com/apache/ssl/apache.crt
        SSLCertificateKeyFile /git/domain2.com/apache/ssl/apache.key

    <Directory /git/domain2.com/public/>
        Options +Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/error_domain2.com.log

</VirtualHost>

</IfModule>
相关问题