如果我有一个逗号分隔的字符串,如何过滤值
How to filter value if i have a string which is comma seprated
我有一个索引,其中有一个 属性 名称的 JobProvince,我需要过滤记录。我有一个字符串
string str = "Friesland,Gelderland"
我正在寻找 JobProvince 是 "Gelderland" 的记录,我正在尝试使用
q.MatchPhrase(c => c.Field(p => p.JobProvincie) .Query(nq => nq.Terms(t => t.Field(tf => tf.JobProvincie.First()).Terms(JobProvinciefacets.Split(',')))))
但没有得到结果。怎么办,求助。
Either convert comma separated values to array while indexing or use comma tokenizer while indexing, post it you will be able to search document using normal term fields
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "pattern",
"pattern": ","
}
}
}
}
逗号分词器link供参考
我使用
得到答案
q.MatchPhrase(a => a.Field(af => af.JobCity).Query(searchLocationLowerCase))
我有一个索引,其中有一个 属性 名称的 JobProvince,我需要过滤记录。我有一个字符串
string str = "Friesland,Gelderland"
我正在寻找 JobProvince 是 "Gelderland" 的记录,我正在尝试使用
q.MatchPhrase(c => c.Field(p => p.JobProvincie) .Query(nq => nq.Terms(t => t.Field(tf => tf.JobProvincie.First()).Terms(JobProvinciefacets.Split(',')))))
但没有得到结果。怎么办,求助。
Either convert comma separated values to array while indexing or use comma tokenizer while indexing, post it you will be able to search document using normal term fields
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "pattern",
"pattern": ","
}
}
}
}
逗号分词器link供参考
我使用
得到答案q.MatchPhrase(a => a.Field(af => af.JobCity).Query(searchLocationLowerCase))