userdefined tokenfilter serializer does not serializer fileds in nest 7.x
Elasticsearch | 作者 mjcak | 发布于2020年01月13日 | 阅读数:1426
### NEST/Elasticsearch.Net version:
7.5.1
### Elasticsearch version:
7.5.0
### Description of the problem including expected versus actual behavior:
Hi , I have the following situation.
I want to create an index from elasticsearch into an c# classs.The problem is that one of the
column from the index is different from my class property name.index column name is : synonyms_path and my class property name is SynonymsPath .
1.
```
public class DynamicRemoteSynonymTokenFilter : TokenFilterBase
{
public DynamicRemoteSynonymTokenFilter() : base("dynamic_synonym")
{
}
[DataMember(Name = "synonyms_path")]
public string SynonymsPath { get; set; }
}
```
2.
```
var de = new CreateIndexDescriptor(indexName)
.Settings(
b => b
.NumberOfShards(3)
.NumberOfReplicas(0)
.Analysis(
c => c.Analyzers(d => d.
Custom("ik", e => e.Tokenizer("ik_max_word").Filters("remote_synonym"))
)
.TokenFilters(tf => tf
//.Synonym("local_synonym", sf => sf.SynonymsPath("analysis/synonym.txt"))
.UserDefined("remote_synonym", new DynamicRemoteSynonymTokenFilter { SynonymsPath = synonymsPath })
)
)
.RefreshInterval(-1)
)
.Map<Goods>(ms => ms.AutoMap());
var result = this.Client.Indices.Create(de);
```
3.
```
{
"settings": {
"index.refresh_interval": -1,
"analysis": {
"analyzer": {
"ik": {
"filter": ["remote_synonym"],
"tokenizer": "ik_max_word",
"type": "custom"
}
},
"filter": {
"remote_synonym": {
"type": "dynamic_synonym"
}
}
},
"index.number_of_shards": 3
}
}
```
4.why "synonyms_path" fields can not be serializer?
Can you give an advice ? What am I doing wrong ?
Thank you.
7.5.1
### Elasticsearch version:
7.5.0
### Description of the problem including expected versus actual behavior:
Hi , I have the following situation.
I want to create an index from elasticsearch into an c# classs.The problem is that one of the
column from the index is different from my class property name.index column name is : synonyms_path and my class property name is SynonymsPath .
1.
```
public class DynamicRemoteSynonymTokenFilter : TokenFilterBase
{
public DynamicRemoteSynonymTokenFilter() : base("dynamic_synonym")
{
}
[DataMember(Name = "synonyms_path")]
public string SynonymsPath { get; set; }
}
```
2.
```
var de = new CreateIndexDescriptor(indexName)
.Settings(
b => b
.NumberOfShards(3)
.NumberOfReplicas(0)
.Analysis(
c => c.Analyzers(d => d.
Custom("ik", e => e.Tokenizer("ik_max_word").Filters("remote_synonym"))
)
.TokenFilters(tf => tf
//.Synonym("local_synonym", sf => sf.SynonymsPath("analysis/synonym.txt"))
.UserDefined("remote_synonym", new DynamicRemoteSynonymTokenFilter { SynonymsPath = synonymsPath })
)
)
.RefreshInterval(-1)
)
.Map<Goods>(ms => ms.AutoMap());
var result = this.Client.Indices.Create(de);
```
3.
```
{
"settings": {
"index.refresh_interval": -1,
"analysis": {
"analyzer": {
"ik": {
"filter": ["remote_synonym"],
"tokenizer": "ik_max_word",
"type": "custom"
}
},
"filter": {
"remote_synonym": {
"type": "dynamic_synonym"
}
}
},
"index.number_of_shards": 3
}
}
```
4.why "synonyms_path" fields can not be serializer?
Can you give an advice ? What am I doing wrong ?
Thank you.
1 个回复
Charele - Cisco4321
赞同来自: