foselasticabundle嵌套条件搜索

时间:2014-11-20 14:04:58

标签: elasticsearch elastica foselasticabundle

这是我的配置

fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        allstock:
            types:
                clip:
                    mappings:
                        clipInfo:
                            type: "nested"
                            properties:
                                title : { boost: 10 }
                                description : { boost: 2 }
                        filterCategories:
                            type: "nested"
                            properties:
                                tags:
                                    type: "nested"
                                    properties:
                                        tag : { boost: 5 }
                                filterCategory:
                                    type: "nested"
                                    properties:
                                        name: ~
                    persistence:
                        driver: orm
                        model: Application\myBundle\Entity\Clip
                        provider: ~
                        listener: ~
                        finder: ~

这是我的索引数据

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 4,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "allstock",
        "_type": "clip",
        "_id": "11",
        "_score": 1.0,
        "_source": {
          "clipInfo": {
            "title": "title 1",
            "description": "some desc"
          },
          "filterCategories": [
            {
              "tags": [
                {
                  "tag": "Interior"
                }
              ],
              "filterCategory": {
                "name": "Setting"
              }
            },
            {
              "tags": [
                {
                  "tag": "Sunny"
                }
              ],
              "filterCategory": {
                "name": "Season"
              }
            }
          ]
        }
      },
      {
        "_index": "allstock",
        "_type": "clip",
        "_id": "12",
        "_score": 1.0,
        "_source": {
          "clipInfo": {
            "title": "title 2",
            "description": "desc 2"
          },
          "filterCategories": [
            {
              "tags": [
                {
                  "tag": "Sunny"
                },
                {
                  "tag": "Rainy"
                }
              ],
              "filterCategory": {
                "name": "Weather"
              }
            },
            {
              "tags": [
                {
                  "tag": "Autumn"
                },
                {
                  "tag": "Winter"
                }
              ],
              "filterCategory": {
                "name": "Season"
              }
            }
          ]
        }
      }
    ]
  }
}

我正在尝试在filterCategories嵌套集合

上构建条件搜索
when tag in tags  == 'sunny'
then name in filterCategory == 'Weather'
{p> tag tagsname filterCategory依赖于其他值。

我怎样才能做到这一点?

0 个答案:

没有答案