【发布时间】:2017-06-25 21:13:29
【问题描述】:
我必须使用 Elasticsearch 摄取插件在 pdf 文档中实现基于全文的搜索。当我尝试在 pdf 文档中搜索单词 someword 时,我得到一个空的命中数组。
//Code for creating pipeline
PUT _ingest/pipeline/attachment
{
"description" : "Extract attachment information",
"processors" : [
{
"attachment" : {
"field" : "data",
"indexed_chars" : -1
}
}
]
}
//Code for creating the index
PUT my_index/my_type/my_id?pipeline=attachment
{
"filename" : "C:\\Users\\myname\\Desktop\\bh1.pdf",
"title" : "Quick",
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}
//Code for searching the word in pdf
GET /my_index/my_type/_search
{
"query": {
"match": {
"data" : {
"query" : "someword"
}
}
}
【问题讨论】:
-
如果您在 PDF 查看器中打开 PDF,是否可以在其中搜索“someword”并找到匹配项?
-
@Alcanzar 是的,它会搜索这个词。
-
这看起来像 stackoverflow.com/questions/37861279/… 的副本——请注意,您的 PUT 语句正在为文件放置一个特定的“数据”。您需要使用 curl 或类似的东西来传递特定的文件数据。你输入的“数据”是
Lorem ipsum dolor sit amet——如果你搜索 Lorem,你会找到一个结果 -
@Alcanzar 我通过在 Kibana 仪表板上运行 GET 搜索 Lorem 进行了验证。但仍然没有命中。
-
@Alcanzar 你能告诉我弹性搜索索引非结构化数据(如 pdf 文件)背后的理论吗?
标签: elasticsearch full-text-search elasticsearch-plugin