Snowball Analyzer not working in Elasticsearch 5.0

var result = ElasticClientSingleton.WriteInstance.CreateIndex(IndexName, d => d.Settings(s => s.
                            Analysis(a => a.
                            Analyzers(ad => ad.
                                Snowball("pluralwordsAnalyzer", descriptor => descriptor.
                                    Language(SnowballLanguage.English))
                            ))).
                            Mappings(dd => dd.Map<ItemSearchEntry>(m => m.AutoMap()
                                 .Properties(o => o.Text(mf => mf
                                         .Name(s => s.ShortDescription)
                                         .Index()
                                         .Fields(f => f
                                             .Text(s => s.Name(oo => oo.ShortDescription.Suffix("raw")).Index())
                                             .Text(s => s.Name(oo => oo.ShortDescription).SearchAnalyzer("pluralwordsAnalyzer").Analyzer("pluralwordsAnalyzer"))
                                            )
                                        )
                                     )
                                  )));

I am adding snowball analyzer at the time of Indexing records. When I search for apple, i get only 1 document and when I search for apples i get 3 documents. I should get 4 documents when i search for apple or apples. Not sure where I am going wrong.

Can you reproduce with curl or CONSOLE syntax? I can probably puzzle out what the client is doing but it'd be useful to remove it from the equation.

@nik9000
below is my indexing query.

{
    	"settings": {
    		"analysis": {
    			"analyzer": {
    				"pluralwordsAnalyzer": {
    					"type": "snowball",
    					"language": "English"
    				}
    			}
    		}
    	},
    	"mappings": {
    		"smartsiteitemsearchentry": {
    			"properties": {
    				"itemId": {
    					"type": "integer"
    				},
    				"shortDescription": {
    					"type": "text",
    					"fields": {
    						"shortDescription": {
    							"type": "text",
    							"analyzer": "pluralwordsAnalyzer",
    							"search_analyzer": "pluralwordsAnalyzer"
    						}
    					}
    				},
    				"searchTerm": {
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					},
    					"type": "text"
    				}
    			}
    		}
    	}
    }

My search query:

{
	"from": 0,
	"size": 100,
	"sort": [{
		"rank": {
			"order": "desc"
		}
	}],
	"query": {
		"bool": {
			"filter": [{
				"match": {
					"shortDescription": {
						"query": "apple",
						"minimum_should_match": 1
					}
				}
			}]
		}
	}
}

This works for me. If you change the search field from shortDescription to shortDescription.shortDescription then yours ought to work. You may want to call the sub-field that is analyzed using the plural analyzer something different so it isn't confusing though.

@nik9000
Damn, I made a silly mistake in the query. Thanks for pointing out.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.