如何使用nest包在字段级创建索引

3wabscal  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(1)|浏览(460)

我需要使用nets包在ElasticSearch中创建字段级索引。我正在使用.NETCore进行开发。
在这个我有字段名称,手机号码,应用程序id,地址,国家。
在搜索过程中,我使用的字段名称,手机号码和应用程序id。所以我需要为上述字段创建索引。
我正在使用以下代码创建索引:

[ElasticProperty(Store=false, Index=FieldIndexOption.not_analyzed)]

我收到以下错误:
找不到类型或命名空间名称“elasticpropertyattribute”(是否缺少using指令或程序集引用?)
找不到类型或命名空间名称“elasticproperty”(是否缺少using指令或程序集引用?)
找不到类型或命名空间名称“store”(是否缺少using指令或程序集引用?)
找不到类型或命名空间名称“index”(是否缺少using指令或程序集引用?)
“fieldindexoption”不包含“未分析”的定义
如果可能的话,我期待简单的工作与用户界面的源代码。
如何为字段创建索引。
谢谢您。。。

mzmfm0qo

mzmfm0qo1#

[elasticproperty(store=false,index=fieldindexoption.not\u分析)]
为了 ElasticType ,已迁移到 ElasticsearchType ,和 ElasticProperty ,它已迁移到特定属性,如 Date , Text 等等。检查基于属性的Map。
下面是一个简单的演示:

[ElasticsearchType(Name = "othername", IdProperty = "MyId")]
public class Foo
{
    [Text(Store = false, Index = true, IndexOptions = IndexOptions.Docs)]
    public Guid MyId { get; set; }
    [Date(Format = "mmddyyyy")]
    public DateTime Date { get; set; }
    [Number(NumberType.Integer, Coerce = true, DocValues = true)]
    public int Number { get; set; }
}

还有一点,检查[5.0 breaking change]字符串->关键字或文本#2384

相关问题