我似乎無法獲得NEST 2.0中多字段映射的語法正確性 - 如果這是正確的術語。我爲映射找到的每個示例似乎都是< = NEST的1.x版本。我是Elasticsearch和NEST的新手,我一直在閱讀他們的文檔,但NEST文檔尚未針對2.x完全更新。使用NEST 2.x創建具有多字段映射語法的索引
基本上,我不需要索引或存儲整個類型。有些字段僅用於建立索引,有些字段需要索引和檢索,有些字段不需要索引,僅用於檢索。
MyType
{
// Index this & allow for retrieval.
int Id { get; set; }
// Index this & allow for retrieval.
// **Also**, in my searching & sorting, I need to sort on this **entire** field, not just individual tokens.
string CompanyName { get; set; }
// Don't index this for searching, but do store for display.
DateTime CreatedDate { get; set; }
// Index this for searching BUT NOT for retrieval/displaying.
string CompanyDescription { get; set; }
// Nest this.
List<MyChildType> Locations { get; set; }
}
MyChildType
{
// Index this & allow for retrieval.
string LocationName { get; set; }
// etc. other properties.
}
我已經有能夠索引整個對象和孩子一樣,用作爲一個例子如下:
client.Index(item, i => i.Index(indexName));
然而,實際的對象比這個更大的不少,我真的不需要它。我發現這看起來像我想我想做的,但在一箇舊版本:multi field mapping elasticsearch
我認爲「映射」是我要去的,但就像我說的,我是新的到Elasticsearch和NEST,我正在嘗試學習術語。
溫柔! :)這是我第一次對SO提出問題。謝謝!
真的很好的答案。似乎主要是爲我工作,但是,我在Nest 2.4.2中使用'.Suffix(「raw」)'有一個問題(它只是不起作用)。我最後使用了'+「.raw」'。 – Harvey