我试图索引一个multiField字符串属性("prueba"),以达到多语言的目的。我的映射正在处理注释。
@MultiField(
mainField = @Field(type = FieldType.String, store = true),
otherFields = {
@NestedField(dotSuffix = "cat", type = FieldType.String, store = true, indexAnalyzer = "catalan", searchAnalyzer = "catalan" ),
@NestedField(dotSuffix = "ba", type = FieldType.String, store = true, indexAnalyzer = "basque", searchAnalyzer = "basque"),
@NestedField(dotSuffix = "gal", type = FieldType.String, store = true, indexAnalyzer = "galician", searchAnalyzer = "galician"),
@NestedField(dotSuffix = "en", type = FieldType.String, store = true, indexAnalyzer = "english", searchAnalyzer = "english")}
)
protected String prueba;结果映射是:
,
"prueba": {
"type": "string",
"store": true,
"fields": {
"prueba.ba": {
"type": "string",
"store": true,
"analyzer": "basque"
},
"prueba.cat": {
"type": "string",
"store": true,
"analyzer": "catalan"
},
"prueba.en": {
"type": "string",
"store": true,
"analyzer": "english"
},
"prueba.gal": {
"type": "string",
"store": true,
"analyzer": "galician"
}
}
},所以,我索引我的对象,但结果只是.‘
IndexQuery query = new IndexQuery();
query.setObject(itemTransparencia);
query.setType(subportal);
String id = this.elasticsearchOperations.index(query);
GET /item_transparencia/432/_search
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "item_transparencia",
"_type": "432",
"_id": "AVTxEfvBhgYXtMQTaKx1",
"_score": 1,
"_source": {
"subportal": "432",
"titulo": null,
"prueba": "prueba la tarta de mi casa",
"subTitulo": null,
"descripcion": null,
"fechaIndexado": "2016-05-我只得到 "prueba ":“prueba la tarta de mi casa"。
-Could有人帮助我理解如何从字段"prueba“、-Does indexAnalyzer =”加泰罗尼亚“、searchAnalyzer =”加泰罗尼亚“中索引或获取嵌套字段,以帮助我自动索引到另一个加长?
太感谢了!
发布于 2016-05-27 08:50:32
多字段prueba.ba、prueba.cat、prueba.en、prueba.gal已经编入索引,但在源文档中看不到它们。
现在,您可以在查询中直接引用它们(映射中声明的分析器将按预期的方式使用),您将得到预期的结果。例如,下面的查询应该返回id AVTxEfvBhgYXtMQTaKx1的文档。
{
"query": {
"match": {
"prueba.ba": "prueba"
}
}
}但是,请注意,在字段上设置语言分析器并不能将字段的内容转换为该分析器的语言,您需要自己去做。
https://stackoverflow.com/questions/37478900
复制相似问题