gpt4 book ai didi

c# - ElasticSearch:为什么索引中的所有文本字段都具有关键字类型?

转载 作者:行者123 更新时间:2023-12-03 01:34:18 26 4
gpt4 key购买 nike

我将NEST与具有属性的类配对使用来推送新文档。
这是我定义类的方法:

public class PatientNestModel
{
[Text]
public string FirstName { get; set; }
[Text]
public string LastName { get; set; }
[Text]
public string MiddleName { get; set; }
[Date(Format = "dd-MM-yyyy")]
public DateTime BirthdayDate { get; set; }
[Keyword]
public string Gender { get; set; }
[Text]
public string Phone { get; set; }
[Nested]
public List<AdditionalContact> AdditionalContacts { get; set; }
[Boolean]
public bool Active { get; set; }
}

这是我的推送方式:
var response = _esClient.Index(model, idx => idx.Index("patients_esindex"));

但是,然后我的索引元数据看起来带有关键字类型。
{
"state": "open",
"settings": {
"index": {
"creation_date": "1543806292300",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "3_J5ck_CTaCLEdhIbCC0ZQ",
"version": {
"created": "6030199"
},
"provided_name": "patients_esindex"
}
},
"mappings": {
"patientnestmodel": {
"properties": {
"firstName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"lastName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"gender": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"birthdayDate": {
"type": "date"
},
"phone": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"active": {
"type": "boolean"
},
"middleName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
}
}
}
},
"aliases": [],
"primary_terms": {
"0": 1,
"1": 1,
"2": 1,
"3": 1,
"4": 1
},
"in_sync_allocations": {
"0": [
"DCbu6-HvQT2ziCzhFZKU6A"
],
"1": [
"9SGADbBfSWuH7AanJUGgRA"
],
"2": [
"dPmhURTzTVWFV4z6Fh8ctw"
],
"3": [
"RHX67o0QQsueD6G67IXAkg"
],
"4": [
"aoBxi-i8Q1aVSeq1tT69Lw"
]
}
}

但是,只有当我将术语与 .keyword一起使用时,我才能通过文本搜索找到所需的文档

我做错了什么?

最佳答案

从ES 5.0开始,字符串字段已分为两种新类型:应该用于全文搜索的文本和应该用于关键字搜索的关键字。

https://www.elastic.co/blog/strings-are-dead-long-live-strings

关于c# - ElasticSearch:为什么索引中的所有文本字段都具有关键字类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53586989/

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