Creating an index with mappings and analysis doesn't work


(Hayk Hovhanisyan) #1

ElasticSearch "2.4.4"
Java "1.8.0_151"

Hi folks,

The first example fails with MapperParsingException[Analyzer [bigrams] not found for field [displayName]];.

here is https://github.com/elastic/elasticsearch/issues/767 similar closed issues.

But about the case when we are using settings.json in resource and spring data annotations (@Setting(settingPath = "/settings/settings.json") in class level, and @Field(type = FieldType.String, analyzer = "bigrams") for corresponding field) .

{  
   "index":{  
      "analysis":{  
         "filter":{  
            "bigrams_filter":{  
               "type":"ngram",
               "min_gram":"2",
               "max_gram":"2"
            }
         },
         "analyzer":{  
            "bigrams":{  
               "type":"custom",
               "tokenizer":"standard",
               "filter":[  
                  "lowercase",
                  "bigrams_filter"
               ]
            }
         }
      }
   }
}

@Setting(settingPath = "/settings/settings.json")
public abstract class AbstractSearchEntity implements Entity {
........
@field(type = FieldType.String, analyzer = "bigrams")
private String displayName;`
..........

}

regards Hayk Hovhannisyan


(Val Crettaz) #2

Where do you store your settings.json file?


(Val Crettaz) #3

The file is supposed to be located in

myproject/src/main/resources/settings/

(Hayk Hovhanisyan) #4

The path is ininvestigation-service/src/main/resources/settings/settings.json.

The error I got because used that file under wrong service resource folder.
My abstract class in core-service, but implementations in investigation-service.
The solution is put it in core-service instead of.

Thank your for your question.

regards


(Val Crettaz) #5

Indeed, the problem was the location of the file. Glad you figured it out!


(system) #6

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