Asciifolding不使用FOSElasticabundle

时间:2017-05-25 10:34:21

标签: symfony elasticsearch elasticsearch-plugin foselasticabundle

我正在使用序列化程序获取字段,并使用stempel插件进行波兰语搜索elasticSearch。试图在这个例子中得到类似的东西,但没有成功:

https://www.elastic.co/guide/en/elasticsearch/guide/current/asciifolding-token-filter.html#asciifolding-token-filter

这是我的配置:

fos_elastica:
    serializer: ~
    clients:
        default: { host: 127.0.0.1, port: 9200 }
    indexes:
        bpo:
            settings:
                index:
                    analysis:
                        analyzer:
                            folding:
                                tokenizer: standard
                                filter: [standard, lowercase, asciifolding, polish_stem]
        types:
            company:
                properties:
                    name:
                        type: string
                        analyzer: standard
                        fields:
                            folded:
                                type: string
                                analyzer: folding
                serializer:
                    groups: [elastica]
                    version: '1.1'
                    serialize_null: true
                persistence:
                    driver: orm
                    model: AppBundle\Entity\Company
                    repository: AppBundle\Repository\CompanyRepository
                    provider: ~
                    finder: ~

然后检查:

$ curl "127.0.0.1:9200/bpo/_analyze?analyzer=folding&text=spółka&pretty"
{
  "tokens" : [ {
    "token" : "spᅢ뺴",
    "start_offset" : 0,
    "end_offset" : 5,
    "type" : "<ALPHANUM>",
    "position" : 0
  }, {
    "token" : "ツ",
    "start_offset" : 5,
    "end_offset" : 6,
    "type" : "<KATAKANA>",
    "position" : 1
  }, {
    "token" : "ka",
    "start_offset" : 6,
    "end_offset" : 8,
    "type" : "<ALPHANUM>",
    "position" : 2
  } ]
}

即使尝试获取ß ⇒ ss

$ curl "127.0.0.1:9200/bpo/_analyze?analyzer=folding&text=ß&pretty"
{
  "tokens" : [ {
    "token" : "ᅢ゚",
    "start_offset" : 0,
    "end_offset" : 2,
    "type" : "<HANGUL>",
    "position" : 0
  } ]
}

当我试图从浏览器获得一些回复 - “spółka”给我正确的数据,但“spolka”什么都不返回。

我需要过滤器,还是什么?

1 个答案:

答案 0 :(得分:1)

我解决了这个问题购买变更分析仪名称来自&#34;折叠&#34;到&#34;默认&#34;。 这项工作适合我。

工作配置:

fos_elastica:
    serializer: ~
    clients:
        default: { host: 127.0.0.1, port: 9200 }
    indexes:
        bpo:
            settings:
                index:
                    analysis:
                        analyzer:
                            default:
                                tokenizer: standard
                                filter: [standard, lowercase, asciifolding, polish_stem]