我的索引数据配置如下。我使用ES 1.1.1和Nest 1.0.0-beta1。
Analyzer
{
"index": {
"analysis": {
"analyzer": {
"allwords": {
"type": "custom",
"tokenizer": "allwords_tokenizer",
"filter": [
"asciifolding",
"lowercase",
"my_stop",
"standard"
]
}
},
"tokenizer": {
"allwords_tokenizer": {
"type": "keyword",
"max_token_length": 255
}
},
"filter": {
"my_stop": {
"type": "stop",
"stopwords": "_none_"
}
}
}
}
}
和
Mapping
{
"properties": {
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"analyzer": "allwords"
}
}
}
}
}
我的ES对象是
[ElasticType(Name = "profile",IdProperty = "Id")]
public class ES_Profile
{
public string Id { get; set; }
[ElasticProperty(Name = "name.raw", Type = FieldType.string_type, SearchAnalyzer = "allwords", Store = false)]
public string name_raw { get; set; }
public string name { get; set; }
}
问题在于索引。没有
[ElasticProperty(Name = "name.raw", Type = FieldType.string_type, SearchAnalyzer = "allwords", Store = false)]
public string name_raw { get; set; }
它完美地工作并索引数据但是当我使用它包含“name_raw”时,它会失败。
我收到了以下回复,无法理解问题。
{
StatusCode: 200,
Method: POST,
Url: http://127.0.0.1:9200/hzmt_x/profile/1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D,
Request: {"id": "1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D", "name": "My Name"
},
Response: {"_index":"hzmt_x","_type":"profile","_id":"1115A2F8-07AE-4E9D-A6CF-7DFF3BD8789D","_version":8,"created":false}}
当我获得索引设置时,我得到了
{
hzmt_x: {
settings: {
index: {
uuid: ahOhgj17QOyCVFcO2aRf1A
analysis: {
filter: {
my_stop: {
type: stop
stopwords: _none_
}
}
analyzer: {
allwords: {
type: custom
filter: [
asciifolding
lowercase
my_stop
standard
]
tokenizer: allwords_tokenizer
}
allwords_tokenizer: {
type: keyword
max_token_length: 255
}
}
}
}
}
}
}
对于制图,我得到了
{
hzmt_x: {
mappings: {
profile: {
properties: {
id: {
type: string
}
name: {
type: string
fields: {
raw: {
type: string
analyzer: allwords
}
}
}
}
}
}
}
}
“name_raw”是一个索引时间分析字段,所以我认为一定没有问题,但我有一个。
我该怎么办?你有什么建议吗?
谢谢, 奥古兹
答案 0 :(得分:0)
您使用的是哪个版本的Nest?更新到最新版本.Below代码适用于我。
var rep = client.CreateIndex("test", c => c
.AddMapping<object>(m => m
.Properties(props => props
.String(ps => ps.Name(""name_raw").IndexAnalyzer("keyword"))
)));