【发布时间】:2014-10-07 19:50:32
【问题描述】:
我有一个名为“IndexModel”的类:
public class IndexModel
{
[ElasticProperty(Index= FieldIndexOption.NotAnalyzed, Store = true)]
public string ModelNumber{ get; set; }
}
以下是我如何设置弹性客户端:
var uri = new Uri("http://localhost:9200");
var config = new ConnectionSettings(uri);
var client = new ElasticClient(config);
client.Map<IndexModel>(m => m.MapFromAttributes());
我可以从响应中看到映射结果:
Request {
"indexmodel": {
"properties": {
"modelNumber": {
"type": "string",
"store": true,
"index": "not_analyzed"
},
}
}
}
我有一个该类型的索引记录,“ModelNumber”属性的值为“test-123”,以下是我的查询:
var result = client.Search<IndexModel>(s => s.Query(new TermQuery() { Field = Property.Path<IndexModel>(it => it.ModelNumber), Value = "test-123"}));
这是我得到的最终映射请求:
Method: POST,
Url: http://localhost:9200/_search,
Request: {
"query": {
"term": {
"modelNumber": {
"value": "test-123"
}
}
}
}
但是我无法得到结果,如果我将“ModelNumber”属性的值更改为“test123”,重新索引它,并通过关键字“test123”搜索它,那么它是有效的,所以我认为分析器仍然分析了“ModelNumber”属性,谁能帮帮我,谢谢。
【问题讨论】:
-
我确实有类似的问题,升级到最新的 NEST 包后。 @Dragon 你有运气吗?
-
这个问题解决了吗?
标签: c# elasticsearch nest