我陷入困境與巢。我在Elasticsearch 5.1.1上有一個全新的索引,我試圖用dotnet core定義一個類型映射。巢映射兩次相同的類型
我的類看起來像:
public class Review
{
public Guid Id { get; set; }
public User User { get; set; }
public Movie Movie { get; set; }
public int Grade { get; set; }
public string Title { get; set; }
public string Comment { get; set; }
public bool HasSpoiler { get; set; }
public bool BoughtInIngresso { get; set; }
public ReviewStatus Status { get; set; }
public DateTime Date { get; set; }
}
public class User
{
public string Id { get; set; }
public string Name { get; set; }
}
public class Movie
{
public string Id { get; set; }
public string Name { get; set; }
}
在我的申請,我試圖定義類型映射(只是爲了測試)的縮寫形式類似:
VAR池=新StaticConnectionPool(節點);
var settings = new ConnectionSettings(pool);
settings.DefaultIndex(elasticSettings.IndexName);
var client = new ElasticClient(settings);
client.Map<Review>(m =>
m.Index("my_index")
.Type("reviews")
.Properties(ps=>
ps.Keyword(k=>
k.Name("title"))
.Text(t=>
t.Name("comment"))
)
);
而最終的結果是這樣的。觀察正在創建的評論和評論映射。我只想要「評論」,而不是「評論」。
{
"my_index": {
"mappings": {
"reviews": {
"properties": {
"comment": {
"type": "text"
},
"title": {
"type": "keyword"
}
}
},
"review": {
"properties": {
"boughtInSite": {
"type": "boolean"
},
"comment": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"date": {
"type": "date"
},
"grade": {
"type": "long"
},
"hasSpoiler": {
"type": "boolean"
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"movie": {
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"status": {
"type": "long"
},
"title": {
"type": "keyword"
},
"user": {
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
}
我在做什麼錯了?如果我使用AutoMap(),也會發生這種情況。我不想映射屬性,因爲我想保留我的POCO類,但如果是唯一的方法,我可以做。
有幫助嗎?