Bib*_*hew 1 rest elasticsearch
我是弹性搜索的新手.我的用例是在一些XML文件集中搜索文本.所以我的问题是.
我尝试了以下方法:
安装了Elastic搜索,应用了附件插件
创建了一个映射:
curl -XPUT 'http://localhost:9200/second/?pretty=1' -d '
{
"mapping" : {
"xmlfile" : {
"properties" : {
"attachment": { "type" : "attachment" }
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
索引XML文件:
curl -XPOST "http://localhost:9200/second/xmlfile?pretty=1" -d '
{
"file" : "'`base64 D:\\games.xml | perl -pe 's/\n/\\n/g'`'"
}
Run Code Online (Sandbox Code Playgroud)
试过搜索:
curl -XGET 'http://localhost:9200/second/xmlfile/_search?pretty=1' -d '
{
"query" : {
"text" : {
"file" : "curField" //currField is a string inside my xml
}
}
}
Run Code Online (Sandbox Code Playgroud)
上面的搜索给了我SearchNotFound Exception所以id
curl -XGET 'http://localhost:9200/second/xmlfile/_search?pretty=1' -d '
{
"query" : {
"term" : {
"file" : "curField" //currField is a string inside my xml
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪个给了我:
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
Run Code Online (Sandbox Code Playgroud)
它说0次点击.我也尝试将我的xml转换为JSON对象和索引.但这对我的计划来说是很多工作.有人可以帮我这个吗?当XML包含字符串时,为什么说0次命中?
1.XML搜索 - 使用弹性搜索是否可以实现
是的,一点没错.但是,我会对你所拥有的方法采取不同的方法.我会改为
| 归档时间: |
|
| 查看次数: |
2843 次 |
| 最近记录: |