[英]Searching documents indexed via ingest-attachment in elasticsearch
Searching documents indexed via ingest-attachment in elastic search on basis of attributes. 在基于属性的弹性搜索中搜索通过摄取附件索引的文档。
i'm new to elastic search and wanted to index files with some of the attributes like Author, Title, Subject, Category, Community etc. 我是弹性搜索的新手,并希望使用某些属性(例如作者,标题,主题,类别,社区等)对文件建立索引。
How far i reached :- 我走了多远:-
i was able to create a attachment pipeline and was able to ingest the different docs in the elastic with attributes. 我能够创建一个附件管道,并且能够使用属性来摄取弹性文档中的不同文档。 see below how i did:-
看看下面我是怎么做的:-
1) created pipeline by following request:- 1)通过以下请求创建管道:
{
"description":"Extract attachment information",
"processors":[
{
"attachment":{
"field":"data"
}
}
]
}
2) upload an attachment via following code :- 2)通过以下代码上传附件:
{
"filename":"Presentations-Tips.ppt",
"Author":"Jaspreet",
"Category":"uploading ppt",
"Subject":"testing ppt",
"fileUrl":"",
"attributes":
{"attr11":"attr11value","attr22":"attr22value","attr33":"attr33value"},
"data": "here_base64_string_of_file"
}
3) then able to search freely on the all the above attributes and on file content as well:- 3)然后可以自由搜索上述所有属性以及文件内容:-
{
"query":{
"query_string":{
"query":"*test*"
}
}
}
Now what I wanted is :- Wanted to narrow down the searches through some filters like :- 现在我想要的是:-想通过一些过滤器来缩小搜索范围:-
Please help me with proper query syntax and call url like for above full text search I used 'GET /my_index/_search' 请使用正确的查询语法为我提供帮助,并致电url,就像上面的全文搜索一样,我使用的是'GET / my_index / _search'
After spending some time finally got the answer:- 花了一些时间终于得到了答案:-
curl -X POST \
http://localhost:9200/my_index/_search \
-H 'Content-Type: application/json' \
-d '{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "progress"
}
},
{
"wildcard": {
"Author": "Rohan"
}
},
{
"wildcard": {
"Title": "q*"
}
}
]
}
}
}'
now in above you can remove or add any object in must array as per your need. 现在,您可以根据需要在must数组中删除或添加任何对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.