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