Chandan Gurjar
Chandan Gurjar

Reputation: 35

ElasticSearch Snowball Analyzer not working with nested query

I have created an index with the following mapping

    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"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

I have put one record using

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"
            }
        }
    }

}

Then if i do a search for the word

breaker

inside

catalogue_product.long_desc.translation.en-GB

I get the added record

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"
                }
            }
        }
    }

}

if replace the word

breaker

with

breakers

, I dont get any records in spite of the en-GB field having analyzer=snowball in the mapping


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"
                }
            }
        }
    }

}

I am going crazy with this. Where am I going wrong? I tried a new mapping with analyzer as english instead of snowball, but that did not work either :( Any help is appreciated

Upvotes: 0

Views: 228

Answers (1)

Vineeth Mohan
Vineeth Mohan

Reputation: 19263

Dude , its a typo. Its analyzer and not anlayzer

   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"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Upvotes: 1

Related Questions