gpt4 book ai didi

elasticsearch - 如何通过使用NEST包在字段级别创建索引

转载 作者:行者123 更新时间:2023-12-03 01:33:46 25 4
gpt4 key购买 nike

我需要通过使用 NETS 软件包在 flex 搜索中创建字段级索引。我正在使用 .net核心进行开发。

在这个我有字段名称,Mobile_number,app_id,地址,国家。

在搜索过程中,我使用的是名称,Mobile_number和app_id。因此,我需要为上述字段创建索引。

我正在使用以下代码创建索引:

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

我收到以下错误:

The type or namespace name 'ElasticPropertyAttribute' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'ElasticProperty' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'Store' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'Index' could not be found (are you missing a using directive or an assembly reference?)

'FieldIndexOption' does not contain a definition for 'not_analyzed'



如果可能的话,我期望使用ui提供简单的工作源代码。

我如何为字段创建索引。

谢谢...

最佳答案

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



对于 ElasticType,它已迁移到 ElasticsearchType,对于 ElasticProperty,它已迁移到特定的属性,例如 DateText等。请检查 Attribute based mapping

这是一个简单的演示:
[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] String -> Keyword or Text #2384

关于elasticsearch - 如何通过使用NEST包在字段级别创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54075021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com