我希望B字段存储在Elasticsearch中,但绝不索引。当我搜索"Nash"时,我不想在B字段中搜索。所以B字段不是用弹性索引的。
[ElasticsearchType(Name = "ES6")]
public class ES6
{
public string A { get; set; }
public string B { get; set; }
}
elasticClient.IndexDocument(new ES6 { A = "John", B = "Nash" });
elasticClient.IndexDocument(new ES6 { A = "Nash", B = "John" });发布于 2018-10-23 13:19:55
如果您希望有一个字段不被索引,您可以使用NEST Attributes来显示字段不应该被索引。
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/attribute-mapping.html
在您的示例中,可能是这样的:
[ElasticsearchType(Name = "ES6")]
public class ES6
{
[Text]
public string A { get; set; }
[Keyword(Index = false)]
public string B { get; set; }
}将其设置为keyword将确保不对其进行分析,而设置Index = false将告诉弹性不对其进行索引。
https://stackoverflow.com/questions/52944601
复制相似问题