symfony - 映射定义具有不受支持的参数 : [store : true]

标签 symfony elasticsearch foselasticabundle

我定义了我的索引 ads如下:

fos_elastica:
    clients:
         default: { host: %elastica_host%, port: %elastica_port% }         
    indexes:
          ads:
            types:                        
                brand:
                    mappings:
                        name:
                            type: string
                            boost: 5
                        slug:
                            type: string
                            boost: 4
                        date : ~
                        isPublished: ~
                        user:
                            type: nested
                            properties: 
                                username: ~
                                email: ~
                    persistence:
                        driver: orm
                        model: Minn\AdsBundle\Entity\Brend
                        elastica_to_model_transformer:
                            service: minn_ads.transformers_elastica.brand
                        provider: ~
                        listener:
                            immediate: ~
                        finder: ~

仅供引用: 1. 就是这样 BrendUser 相关联与@ManyToOne
/**
 * @ORM\ManyToOne(targetEntity="Minn\UserBundle\Entity\User")
 * @ORM\JoinColumn(nullable=false)
 */
private $user;

仅供引用: 2. 我正在使用dev-master FOSElasticaBundle 和 Elastica 的分支。对于elasticsearch,我使用的是2.1.1。

填充命令 php app/console fos:elastica:populate总是返回这个错误:

[弹性\异常\响应异常]
{"root_cause":[{"type":"mapper_parsing_exception","re​​ason":"[user] 的映射定义有不受支持的参数:[store : true]"}],"type":"mapper_parsing_exception","re​​ason":"无法解析映射 [品牌]:
[user] 的映射定义具有不受支持的参数:[store : true]","caused_by":{"type":"mapper_parsing_exception","re​​ason":"[user] 的映射定义具有不受支持的参数:[store : true] "}}


我查了app/logs/dev.log ,我发现为索引ads生成的映射有一个额外的参数"store":true .你可以检查一下:

[2015-12-20 21:28:21] elastica.DEBUG: 记录请求 {"path":"ads/","method":"PUT","data":{"mappings":{"brand": {"properties":{"name":{"type":"string","boost":5,"store":true},"slug":{"type":"string","boost":4 ,"store":true},"date":{"type":"string","store":true},"isPublished":{"type":"string","store":true},"user ":{"type":"nested","properties":{"username":{"type":"string","store":true},"email":{"type":"string","store":true}},"store":true}},"dynamic_date_formats":[],"_meta":{"model":"Minn\AdsBundle\Entity\Brend"}}}},"query":[ ],"connection":{"config":{"headers":[]},"host":"127.0.0.1","port":9200,"logger":"fos_elastica.logger","enabled":真}} []

下面是带有额外 "store": true 的映射.有没有关于如何配置 FOSElasticaBundle 以在没有这条额外行的情况下使用 "store": true 的映射的任何想法? ?
{
    "mappings": {
        "brand": {
            "properties": {
                "name": {
                    "type": "string",
                    "boost": 5,
                    "store": true
                },
                "slug": {
                    "type": "string",
                    "boost": 4,
                    "store": true
                },
                "date": {
                    "type": "string",
                    "store": true
                },
                "isPublished": {
                    "type": "string",
                    "store": true
                },
                "user": {
                    "type": "nested",
                    "properties": {
                        "username": {
                            "type": "string",
                            "store": true
                        },
                        "email": {
                            "type": "string",
                            "store": true
                        }
                    },
                    "store": true  # extra line! If deleted, it will work!
                }
            }
        }
    }
}

最佳答案

MappingBuilder.php 中有一个错误尝试添加 store: true每当 store property is not specified .

您可以尝试明确指定 store: false使!isset($property['store'])测试失败:

                mappings:
                    name:
                        type: string
                        boost: 5
                    slug:
                        type: string
                        boost: 4
                    date : ~
                    isPublished: ~
                    user:
                        type: nested
                        store: false        <---
                        properties: 
                            username: ~
                            email: ~

您可以尝试的另一件事是修改私有(private) $skipTypes 要包含 nested 的数组除了 completion ,这可以解决问题。

关于symfony - 映射定义具有不受支持的参数 : [store : true],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34383994/

相关文章:

javascript - 如何为 requireJs 使用 Assetic

symfony - Twig 读取图像高度/宽度属性

elasticsearch - 如何将logstash中的日志/txt文件管道传输到elasticsearch

symfony - Doctrine2和FOSElasticaBundle之间的同步不是实时的吗?

symfony - 使用FOSElasticaBundle多次搜索关键字

symfony - 我如何在 twig (symfony2) 中使用 Tinymce

php - json 的 symfony 3 规范器 - 格式化所有时间戳

java - 在java中动态构建elasticsearch boolean 查询

elasticsearch - 如何在Elasticsearch中支持最简单,最精确的字段匹配

elasticsearch - Elasticsearch-如何在一个字符串中搜索多个单词