【发布时间】:2017-04-17 09:41:00
【问题描述】:
我正在使用 ElasticSearch 5,但找不到以下解决方案: 我想在文档中搜索带有斜杠(url 的一部分)的字符串。但它不会返回匹配的文档。 我读过一些带有斜线的字符串被 ES 分割的东西,这不是我想要的这个字段。我尝试使用映射在字段上设置“not_analyzed”,但我似乎无法让它以某种方式工作。
“创建索引”: 把http://localhost:9200/test
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"field1" : { "type" : "text","index": "not_analyzed" }
}
}
}
}
“添加文档”:POST http://localhost:9200/test/type1/
{
"field1" : "this/is/a/url/test"
}
“搜索文档”POST http://localhost:9200/test/type1/_search
{
"size" : 1000,
"query" : {
"bool" : {
"must" : [{
"term" : {
"field1" : {
"value" : "this/is/a/url/test"
}
}
}
]
}
}
}
回复:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
“映射响应”:GET http://localhost:9200/test/_mapping?pretty
{
"test": {
"mappings": {
"type1": {
"properties": {
"field1": {
"type": "text"
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch