ElasticSearch Snowball Analyzer不使用嵌套查询

时间:2015-02-20 13:48:43

标签: elasticsearch analyzer nested-query

我使用以下映射创建了一个索引

    PUT http://localhost:9200/test1
   {
    "mappings": {
        "searchText": {
            "properties": {
                "catalogue_product": {
                    "type":"nested",
                    "properties": {
                        "id": {
                            "type": "string",
                             "index":"not_analyzed"
                        },
                        "long_desc": {
                            "type":"nested",
                            "properties": {
                                "translation": {
                                    "type":"nested",
                                    "properties": {
                                        "en-GB": {
                                            "type": "string",
                                            "anlayzer": "snowball"
                                        },
                                        "fr-FR": {
                                            "type": "string",
                                            "anlayzer": "snowball"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

我使用

放了一条记录
PUT http://localhost:9200/test1/searchText/1
{
    "catalogue_product": {
        "id": "18437",
        "long_desc": {
            "translation": {
                "en-GB": "C120 - circuit breaker - C120H - 4P - 125A - B curve",
                "fr-FR": "Disjoncteur C120H 4P 125A courbe B 15000A"
            }
        }
    }

}

然后,如果我搜索单词

  

断路器

里面

  

catalogue_product.long_desc.translation.en-GB

我得到了补充记录

POST http://localhost:9200/test1/searchText/_search
{
    "query": {
        "nested": {
            "path": "catalogue_product.long_desc.translation",
            "query": {
                "match": {
                    "catalogue_product.long_desc.translation.en-GB": "breaker"
                }
            }
        }
    }

}

如果替换

这个词
  

断路器

  

断路器

,尽管en-GB字段在映射中有分析器=雪球,但我没有得到任何记录


POST http://localhost:9200/test1/searchText/_search
{
    "query": {
        "nested": {
            "path": "catalogue_product.long_desc.translation",
            "query": {
                "match": {
                    "catalogue_product.long_desc.translation.en-GB": "breakers"
                }
            }
        }
    }

}

我为此疯狂。我哪里错了? 我尝试用分析仪作为英语而不是雪球的新映射,但这也不起作用:( 任何帮助表示赞赏

1 个答案:

答案 0 :(得分:1)

老兄,这是一个错字。它是分析仪而不是分析仪

   PUT http://localhost:9200/test1
   {
    "mappings": {
        "searchText": {
            "properties": {
                "catalogue_product": {
                    "type":"nested",
                    "properties": {
                        "id": {
                            "type": "string",
                             "index":"not_analyzed"
                        },
                        "long_desc": {
                            "type":"nested",
                            "properties": {
                                "translation": {
                                    "type":"nested",
                                    "properties": {
                                        "en-GB": {
                                            "type": "string",
                                            "analyzer": "snowball"
                                        },
                                        "fr-FR": {
                                            "type": "string",
                                            "analyzer": "snowball"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}